diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-12-24 10:53:18 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-12-24 10:53:18 (GMT) |
commit | da31ba9b9263c34378a2f141a67ce7fc6ab1289b (patch) | |
tree | 83c4d167a6e2035508b1a15b7b12763a69009549 /Lib/test | |
parent | 7e930d76776157aeed3af521fd3a3fa887236d20 (diff) | |
parent | e9ae5f9b1673145eb81f1a19860b3d7a2decfd9c (diff) | |
download | cpython-da31ba9b9263c34378a2f141a67ce7fc6ab1289b.zip cpython-da31ba9b9263c34378a2f141a67ce7fc6ab1289b.tar.gz cpython-da31ba9b9263c34378a2f141a67ce7fc6ab1289b.tar.bz2 |
Issue #28815: Merge test_socket fix from 3.5
Diffstat (limited to 'Lib/test')
-rw-r--r-- | 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 index 6b29e18..92e727d 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -4778,9 +4778,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 |