(original) (raw)

changeset: 105815:48b9d9cdfe3b branch: 3.6 parent: 105811:ef53ef8e09e5 parent: 105814:7889d7a771c7 user: Martin Panter vadmium+py@gmail.com date: Sat Dec 24 10:53:18 2016 +0000 files: Lib/test/test_socket.py description: Issue #28815: Merge test_socket fix from 3.5 diff -r ef53ef8e09e5 -r 48b9d9cdfe3b Lib/test/test_socket.py --- a/Lib/test/test_socket.py Sat Dec 24 10:21:30 2016 +0000 +++ b/Lib/test/test_socket.py Sat Dec 24 10:53:18 2016 +0000 @@ -4778,9 +4778,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 /vadmium+py@gmail.com