summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-12-24 11:24:45 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-12-24 11:24:45 (GMT)
commit871e01885c6ee720ea996fb4b959402baceb1a53 (patch)
tree362580950e864edbd0ee2533a4580d8355cb30ff
parent5a625d0aa6a6d9ec6574ee8344b41d63dcb9897e (diff)
parentda31ba9b9263c34378a2f141a67ce7fc6ab1289b (diff)
downloadcpython-871e01885c6ee720ea996fb4b959402baceb1a53.zip
cpython-871e01885c6ee720ea996fb4b959402baceb1a53.tar.gz
cpython-871e01885c6ee720ea996fb4b959402baceb1a53.tar.bz2
Issue #28815: Merge test_socket fix from 3.6
-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 a063dbd..b902633 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -4796,9 +4796,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