From: Pablo Galindo Date: Wed, 1 Apr 2020 00:48:37 +0000 (+0100) Subject: Handle when IOCTL_VM_SOCKETS_GET_LOCAL_CID does not exist in "socket" (GH-19270) X-Git-Tag: v3.9.0a6~226 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6eb9619c88612565b424be14196a8adae6d51978;p=thirdparty%2FPython%2Fcpython.git Handle when IOCTL_VM_SOCKETS_GET_LOCAL_CID does not exist in "socket" (GH-19270) Running `test_socket` or anything that depends on it (like python -m test.pythoninfo) crashes if IOCTL_VM_SOCKETS_GET_LOCAL_CID does not exist in the socket module. Automerge-Triggered-By: @pablogsal --- diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 64e95ea34b99..6e4e4fe4c353 100755 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -49,6 +49,8 @@ except ImportError: def get_cid(): if fcntl is None: return None + if not hasattr(socket, 'IOCTL_VM_SOCKETS_GET_LOCAL_CID'): + return None try: with open("/dev/vsock", "rb") as f: r = fcntl.ioctl(f, socket.IOCTL_VM_SOCKETS_GET_LOCAL_CID, " ")