Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1e2784e

Browse files
author
Xavier de Gaye
committed
Issue #26935: Merge 3.6
2 parents afa94a5 + 2106010 commit 1e2784e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Lib/test/test_os.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
try:
5757
import pwd
5858
all_users = [u.pw_uid for u in pwd.getpwall()]
59-
except ImportError:
59+
except (ImportError, AttributeError):
6060
all_users = []
6161
try:
6262
from _testcapi import INT_MAX, PY_SSIZE_T_MAX
@@ -1423,7 +1423,12 @@ def test_urandom_fd_reopened(self):
14231423
break
14241424
os.closerange(3, 256)
14251425
with open({TESTFN!r}, 'rb') as f:
1426-
os.dup2(f.fileno(), fd)
1426+
new_fd = f.fileno()
1427+
# Issue #26935: posix allows new_fd and fd to be equal but
1428+
# some libc implementations have dup2 return an error in this
1429+
# case.
1430+
if new_fd != fd:
1431+
os.dup2(new_fd, fd)
14271432
sys.stdout.buffer.write(os.urandom(4))
14281433
sys.stdout.buffer.write(os.urandom(4))
14291434
""".format(TESTFN=support.TESTFN)

0 commit comments

Comments
 (0)