Skip to content

Commit f2b83c7

Browse files
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 6eb9619) Co-authored-by: Pablo Galindo <[email protected]>
1 parent ad8e56d commit f2b83c7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Lib/test/test_socket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
def get_cid():
4848
if fcntl is None:
4949
return None
50+
if not hasattr(socket, 'IOCTL_VM_SOCKETS_GET_LOCAL_CID'):
51+
return None
5052
try:
5153
with open("/dev/vsock", "rb") as f:
5254
r = fcntl.ioctl(f, socket.IOCTL_VM_SOCKETS_GET_LOCAL_CID, " ")

0 commit comments

Comments
 (0)