8000 closes bpo-37405: Make socket.getsockname() always return a tuple for… · python/cpython@954900a · GitHub
[go: up one dir, main page]

Skip to content

Commit 954900a

Browse files
bggardnerbenjaminp
authored andcommitted
closes bpo-37405: Make socket.getsockname() always return a tuple for AF_CAN. (GH-14392)
This fixes a regression from 3.5. In recent releases, `getsockname()` in the AF_CAN case has returned a string.
1 parent 64535fc commit 954900a

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Lib/test/test_socket.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,9 @@ def testCreateBCMSocket(self):
19481948

19491949
def testBindAny(self):
19501950
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
1951-
s.bind(('', ))
1951+
address = ('', )
1952+
s.bind(address)
1953+
self.assertEqual(s.getsockname(), address)
19521954

19531955
def testTooLongInterfaceName(self):
19541956
# most systems limit IFNAMSIZ to 16, take 1024 to be sure
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed regression bug for socket.getsockname() for non-CAN_ISOTP AF_CAN
2+
address family sockets by returning a 1-tuple instead of string.

Modules/socketmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
15631563
#endif /* CAN_ISOTP */
15641564
default:
15651565
{
1566-
return Py_BuildValue("O&", PyUnicode_DecodeFSDefault,
1566+
return Py_BuildValue("(O&)", PyUnicode_DecodeFSDefault,
15671567
ifname);
15681568
}
15691569
}

0 commit comments

Comments
 (0)
0