diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 50094de58bf1c9..2cd177ed1a10e2 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1920,7 +1920,9 @@ def testCreateBCMSocket(self): def testBindAny(self): with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: - s.bind(('', )) + address = ('', ) + s.bind(address) + self.assertEqual(s.getsockname(), address) def testTooLongInterfaceName(self): # most systems limit IFNAMSIZ to 16, take 1024 to be sure diff --git a/Misc/NEWS.d/next/Library/2019-09-11-20-27-41.bpo-37405.MG5xiY.rst b/Misc/NEWS.d/next/Library/2019-09-11-20-27-41.bpo-37405.MG5xiY.rst new file mode 100644 index 00000000000000..09e10973422106 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-09-11-20-27-41.bpo-37405.MG5xiY.rst @@ -0,0 +1,2 @@ +Fixed regression bug for socket.getsockname() for non-CAN_ISOTP AF_CAN +address family sockets by returning a 1-tuple instead of string. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 73e64f235a6f2d..81b8a0677b19d5 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1513,7 +1513,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto) #endif /* CAN_ISOTP */ default: { - return Py_BuildValue("O&", PyUnicode_DecodeFSDefault, + return Py_BuildValue("(O&)", PyUnicode_DecodeFSDefault, ifname); } }