diff options
| author | Martin Panter <vadmium+py@gmail.com> | 2016-12-24 10:41:37 (GMT) |
|---|---|---|
| committer | Martin Panter <vadmium+py@gmail.com> | 2016-12-24 10:41:37 (GMT) |
| commit | 500794dc0165d7b4404c8503b5d430bc749c9582 (patch) | |
| tree | 46b02816f4c3d464607adaa24bc4b4dbc39abb04 /Lib/test | |
| parent | 427ca62dde4233c9b4065f3e4139ce0e5ce5b752 (diff) | |
| download | cpython-500794dc0165d7b4404c8503b5d430bc749c9582.zip cpython-500794dc0165d7b4404c8503b5d430bc749c9582.tar.gz cpython-500794dc0165d7b4404c8503b5d430bc749c9582.tar.bz2 | |
Issue #28815: Skip TIPC tests if /proc/modules is not readable
Based on patch by Patrila.
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 765d7c0..2b20a79 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1707,9 +1707,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 |
