diff options
author | Xavier de Gaye <xdegaye@users.sourceforge.net> | 2016-11-16 07:06:12 (GMT) |
---|---|---|
committer | Xavier de Gaye <xdegaye@users.sourceforge.net> | 2016-11-16 07:06:12 (GMT) |
commit | 1e2784e0b3cb8d9050bffb338b2de838fbba13a2 (patch) | |
tree | 6f07d1ab5fdd9b8108b859864e5b01beeaeb1b9c | |
parent | afa94a5a3ec7ef66f00fc5ab284d2665f04996be (diff) | |
parent | 21060105d99a9153db44dd88eb750965392fd966 (diff) | |
download | cpython-1e2784e0b3cb8d9050bffb338b2de838fbba13a2.zip cpython-1e2784e0b3cb8d9050bffb338b2de838fbba13a2.tar.gz cpython-1e2784e0b3cb8d9050bffb338b2de838fbba13a2.tar.bz2 |
Issue #26935: Merge 3.6
-rw-r--r-- | Lib/test/test_os.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 628c61e..b3d0b1e 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -56,7 +56,7 @@ except ImportError: try: import pwd all_users = [u.pw_uid for u in pwd.getpwall()] -except ImportError: +except (ImportError, AttributeError): all_users = [] try: from _testcapi import INT_MAX, PY_SSIZE_T_MAX @@ -1423,7 +1423,12 @@ class URandomFDTests(unittest.TestCase): break os.closerange(3, 256) with open({TESTFN!r}, 'rb') as f: - os.dup2(f.fileno(), fd) + new_fd = f.fileno() + # Issue #26935: posix allows new_fd and fd to be equal but + # some libc implementations have dup2 return an error in this + # case. + if new_fd != fd: + os.dup2(new_fd, fd) sys.stdout.buffer.write(os.urandom(4)) sys.stdout.buffer.write(os.urandom(4)) """.format(TESTFN=support.TESTFN) |