[Python-checkins] cpython (3.5): Issue #28815: Skip TIPC tests if /proc/modules is not readable
martin.panter
python-checkins at python.org
Sat Dec 24 06:38:40 EST 2016
https://hg.python.org/cpython/rev/7889d7a771c7
changeset: 105814:7889d7a771c7
branch: 3.5
parent: 105810:3f94e3c7dcc5
user: Martin Panter <vadmium+py at gmail.com>
date: Sat Dec 24 10:41:37 2016 +0000
summary:
Issue #28815: Skip TIPC tests if /proc/modules is not readable
Based on patch by Patrila.
files:
Lib/test/test_socket.py | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -4717,9 +4717,17 @@
"""
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
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list