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 <Pablogsal@gmail.com>
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, " ")