Issue 30205: socket.getsockname() type mismatch with AF_UNIX on Linux (original) (raw)

Created on 2017-04-29 08:55 by giampaolo.rodola, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1370 merged pitrou,2017-05-01 21:39
PR 1404 merged pitrou,2017-05-02 22:04
PR 1403 merged pitrou,2017-05-02 22:05
Messages (11)
msg292580 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2017-04-29 08:55
>>> import socket >>> s = socket.socket(socket.AF_UNIX) >>> s.getsockname() b'' >>> s.bind('foo') >>> s.getsockname() 'foo'
msg292581 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2017-04-29 09:03
The change was introduced here: https://github.com/python/cpython/commit/b10c71daa2099c450101e5854fd693a405bec49c
msg292702 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-05-01 21:37
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'
msg292776 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-05-02 15:20
New changeset 495b5021e73e3c4b6404417ecf4fa83aa10297f0 by Antoine Pitrou in branch 'master': bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux (#1370) https://github.com/python/cpython/commit/495b5021e73e3c4b6404417ecf4fa83aa10297f0
msg292781 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2017-05-02 15:38
Thanks.
msg292806 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-02 21:19
Test fails on x86 Tiger 3.x: http://buildbot.python.org/all/builders/x86%20Tiger%203.x/builds/600/steps/test/logs/stdio ====================================================================== FAIL: testUnbound (test.test_socket.TestUnixDomain) ---------------------------------------------------------------------- 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 != ''
msg292807 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-02 21:20
Maybe restrict the unit test to Linux since the change was specific to Linux?
msg292809 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-05-02 21:27
Oh, yuck. > Maybe restrict the unit test to Linux since the change was specific to Linux? That sounds reasonable. I didn't know getsockname() could return None...
msg292810 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-02 21:32
> 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; }
msg292818 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-05-02 22:14
New changeset 0c2ff0898db2db9cd9c643dfadbff11761bacf5f by Antoine Pitrou in branch '3.6': Backport bpo-30205 to 3.6 (#1403) https://github.com/python/cpython/commit/0c2ff0898db2db9cd9c643dfadbff11761bacf5f
msg292819 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-05-02 22:22
New changeset 0d9d61828bbd6cbc289489bf1d439fa91eca3743 by Antoine Pitrou in branch '3.5': Backport bpo-30205 to 3.5 (#1404) https://github.com/python/cpython/commit/0d9d61828bbd6cbc289489bf1d439fa91eca3743
History
Date User Action Args
2022-04-11 14:58:45 admin set github: 74391
2017-05-02 22:23:04 pitrou set status: open -> closedresolution: fixedstage: needs patch -> resolved
2017-05-02 22:22:30 pitrou set messages: +
2017-05-02 22:14:31 pitrou set messages: +
2017-05-02 22:05:32 pitrou set pull_requests: + <pull%5Frequest1512>
2017-05-02 22:04:08 pitrou set pull_requests: + <pull%5Frequest1511>
2017-05-02 21:32:09 vstinner set messages: +
2017-05-02 21:27:12 pitrou set nosy: + ronaldoussoren, ned.deilymessages: +
2017-05-02 21:20:26 vstinner set messages: +
2017-05-02 21:19:32 vstinner set nosy: + vstinnermessages: +
2017-05-02 15:38:11 giampaolo.rodola set messages: +
2017-05-02 15:20:04 pitrou set messages: +
2017-05-01 21:52:13 christian.heimes set nosy: + christian.heimes
2017-05-01 21:39:43 pitrou set pull_requests: + <pull%5Frequest1479>
2017-05-01 21:37:09 pitrou set type: behaviorcomponents: + Library (Lib)versions: + Python 3.5, Python 3.6, Python 3.7, - Python 2.7nosy: + pitroumessages: + stage: needs patch
2017-04-29 09:03:15 giampaolo.rodola set nosy: + neologixmessages: + versions: + Python 2.7
2017-04-29 08:55:10 giampaolo.rodola create