]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Handle when IOCTL_VM_SOCKETS_GET_LOCAL_CID does not exist in "socket" (GH-19270)
authorPablo Galindo <Pablogsal@gmail.com>
Wed, 1 Apr 2020 00:48:37 +0000 (01:48 +0100)
committerGitHub <noreply@github.com>
Wed, 1 Apr 2020 00:48:37 +0000 (17:48 -0700)
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
Lib/test/test_socket.py

index 64e95ea34b99730688eff599520cebb1709ed482..6e4e4fe4c353211c99158ffe4a1d5e94ad808594 100755 (executable)
@@ -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, "    ")