Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9ae5f9

Browse files
committed
Issue #28815: Skip TIPC tests if /proc/modules is not readable
Based on patch by Patrila.
1 parent 7106a51 commit e9ae5f9

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Lib/test/test_socket.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4717,9 +4717,17 @@ def isTipcAvailable():
47174717
"""
47184718
if not hasattr(socket, "AF_TIPC"):
47194719
return False
4720-
if not os.path.isfile("/proc/modules"):
4721-
return False
4722-
with open("/proc/modules") as f:
4720+
try:
4721+
f = open("/proc/modules")
4722+
except IOError as e:
4723+
# It's ok if the file does not exist, is a directory or if we
4724+
# have not the permission to read it. In any other case it's a
4725+
# real error, so raise it again.
4726+
if e.errno in (errno.ENOENT, errno.EISDIR, errno.EACCES):
4727+
return False
4728+
else:
4729+
raise
4730+
with f:
47234731
for line in f:
47244732
if line.startswith("tipc "):
47254733
return True

0 commit comments

Comments
 (0)