From 8282d7cf8d35c37851cda23317e250dc34fb8b20 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Wed, 1 Apr 2020 01:15:10 +0100 Subject: [PATCH] Handle when IOCTL_VM_SOCKETS_GET_LOCAL_CID does not exist in "socket" 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. --- Lib/test/test_socket.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 64e95ea34b9973..6e4e4fe4c35321 100755 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -49,6 +49,8 @@ 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, " ")