Issue #28815: Merge test_socket fix from 3.6

This commit is contained in:
Martin Panter 2016-12-24 11:24:45 +00:00
commit 871e01885c
1 changed files with 11 additions and 3 deletions

View File

@ -4796,9 +4796,17 @@ def isTipcAvailable():
""" """
if not hasattr(socket, "AF_TIPC"): if not hasattr(socket, "AF_TIPC"):
return False return False
if not os.path.isfile("/proc/modules"): try:
return False f = open("/proc/modules")
with open("/proc/modules") as f: 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: for line in f:
if line.startswith("tipc "): if line.startswith("tipc "):
return True return True