Skip to content

Commit 6acafee

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 40e1b04 commit 6acafee

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Lib/test/test_socket.py

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
def get_cid():
5151
if fcntl is None:
5252
return None
53+
if not hasattr(socket, 'IOCTL_VM_SOCKETS_GET_LOCAL_CID'):
54+
return None
5355
try:
5456
with open("/dev/vsock", "rb") as f:
5557
r = fcntl.ioctl(f, socket.IOCTL_VM_SOCKETS_GET_LOCAL_CID, " ")

0 commit comments

Comments
 (0)