-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-37405: socket.getsockname() returns string instead of tuple #14392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test at
cpython/Lib/test/test_socket.py
Line 1923 in c6a2320
s.bind(('', )) |
s.getsockname()
to return a tuple instead of a string. I think this also requires a NEWS entry since there is change in the type of return value.
A couple questions, as I am new to contributing:
|
Sorry, I thought this was fixing a regression. Looking at the commit I am not sure if it was intentional or missed to return a string. I would wait for a core dev input on this. |
Hi, to answer your question, no, this was not intentional. |
Agreed. I never understood why socket.AF_CAN was included in the tuple, so I'll update the pull request with @pylessard 's suggestion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have NEWS note because the regression was released.
Lib/test/test_socket.py
Outdated
@@ -1921,6 +1921,7 @@ def testCreateBCMSocket(self): | |||
def testBindAny(self): | |||
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: | |||
s.bind(('', )) | |||
self.assertIsInstance(s.getsockname(), tuple) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make the more specific assertion here that s.getsockname() == ('',)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so, even though it isn't the greatest of tests to begin with. I'll make the change anyway.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @benjaminp: please review the changes made to this pull request. |
Thanks @bggardner for the PR, and @benjaminp for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
… AF_CAN. (pythonGH-14392) This fixes a regression from 3.5. In recent releases, `getsockname()` in the AF_CAN case has returned a string. (cherry picked from commit 954900a) Co-authored-by: bggardner <brent@ebrent.net>
GH-16018 is a backport of this pull request to the 3.8 branch. |
… AF_CAN. (pythonGH-14392) This fixes a regression from 3.5. In recent releases, `getsockname()` in the AF_CAN case has returned a string.
https://bugs.python.org/issue37405