mirror of
https://github.com/python/cpython.git
synced 2025-08-19 08:11:46 +00:00
closes bpo-37405: Make socket.getsockname() always return a tuple for AF_CAN. (GH-14392) (GH-16018)
This fixes a regression from 3.5. In recent releases, `getsockname()` in the AF_CAN case has returned a string.
(cherry picked from commit 954900a3f9
)
Co-authored-by: bggardner <brent@ebrent.net>
This commit is contained in:
parent
52baf90a74
commit
f60fd95dcc
3 changed files with 6 additions and 2 deletions
|
@ -1897,7 +1897,9 @@ class BasicCANTest(unittest.TestCase):
|
||||||
|
|
||||||
def testBindAny(self):
|
def testBindAny(self):
|
||||||
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
|
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):
|
def testTooLongInterfaceName(self):
|
||||||
# most systems limit IFNAMSIZ to 16, take 1024 to be sure
|
# most systems limit IFNAMSIZ to 16, take 1024 to be sure
|
||||||
|
|
|
@ -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.
|
|
@ -1524,7 +1524,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
|
||||||
#endif /* CAN_ISOTP */
|
#endif /* CAN_ISOTP */
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
return Py_BuildValue("O&", PyUnicode_DecodeFSDefault,
|
return Py_BuildValue("(O&)", PyUnicode_DecodeFSDefault,
|
||||||
ifname);
|
ifname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue