From cf372e86b8faff5c1321009e1c736b4fe53612bf Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Wed, 1 Apr 2020 01:48:37 +0100 Subject: [PATCH] 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 (cherry picked from commit 6eb9619c88612565b424be14196a8adae6d51978) Co-authored-by: Pablo Galindo --- 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 1bf562a03d556c..f9370d8e52dca1 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -50,6 +50,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, " ")