summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-12-24 10:41:37 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-12-24 10:41:37 (GMT)
commite9ae5f9b1673145eb81f1a19860b3d7a2decfd9c (patch)
tree1e4c1d0124a5118e80d590a4f2196146f033e218 /Lib/test/test_socket.py
parent7106a51c7130eb9ba9c1bb380c23da6eb53c257e (diff)
downloadcpython-e9ae5f9b1673145eb81f1a19860b3d7a2decfd9c.zip
cpython-e9ae5f9b1673145eb81f1a19860b3d7a2decfd9c.tar.gz
cpython-e9ae5f9b1673145eb81f1a19860b3d7a2decfd9c.tar.bz2
Issue #28815: Skip TIPC tests if /proc/modules is not readable
Based on patch by Patrila.
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index dbfcab8..ea3ca28 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -4717,9 +4717,17 @@ def isTipcAvailable():
"""
if not hasattr(socket, "AF_TIPC"):
return False
- if not os.path.isfile("/proc/modules"):
- return False
- with open("/proc/modules") as f:
+ try:
+ f = open("/proc/modules")
+ except IOError as e:
+ # It's ok if the file does not exist, is a directory or if we
+ # have not the permission to read it. In any other case it's a
+ # real error, so raise it again.
+ if e.errno in (errno.ENOENT, errno.EISDIR, errno.EACCES):
+ return False
+ else:
+ raise
+ with f:
for line in f:
if line.startswith("tipc "):
return True