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
socket.getsockname() type mismatch with AF_UNIX on Linux #74391
Comments
>>> import socket
>>> s = socket.socket(socket.AF_UNIX)
>>> s.getsockname()
b''
>>> s.bind('foo')
>>> s.getsockname()
'foo' |
The change was introduced here: |
Amusingly, binding to the empty string produces something different: >>> s = socket.socket(socket.AF_UNIX)
>>> s.getsockname()
b''
>>> s.bind(b'')
>>> s.getsockname()
b'\x000005d' while binding to the nul byte string produces the expected result: >>> s = socket.socket(socket.AF_UNIX)
>>> s.bind(b'\x00')
>>> s.getsockname()
b'\x00' |
Thanks. |
Test fails on x86 Tiger 3.x: http://buildbot.python.org/all/builders/x86%20Tiger%203.x/builds/600/steps/test/logs/stdio ====================================================================== Traceback (most recent call last):
File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_socket.py", line 4687, in testUnbound
self.assertEqual(self.sock.getsockname(), '')
AssertionError: None != '' |
Maybe restrict the unit test to Linux since the change was specific to Linux? |
Oh, yuck.
That sounds reasonable. I didn't know getsockname() could return None... |
Me neither. Maybe it's a bug? makesockaddr() returns None if addrlen equals 0:
if (addrlen == 0) {
/* No address -- may be recvfrom() from known socket */
Py_RETURN_NONE;
} |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: