Skip to content

Commit

Permalink
add comment to clarify the code
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Jan 10, 2024
1 parent 0547f21 commit dcdc5ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -4490,12 +4490,14 @@ def test_pipe_spawnl(self):
# gh-77046: On Windows, os.pipe() file descriptors must be created with
# _O_NOINHERIT to make them non-inheritable. UCRT has no public API to
# get (_osfile(fd) & _O_NOINHERIT), so use a functional test.
#
# Make sure that fd is not inherited by a child process created by
# os.spawnl(): get_osfhandle() and dup() must fail with EBADF.

fd, fd2 = os.pipe()
self.addCleanup(os.close, fd)
self.addCleanup(os.close, fd2)

# Make sure that fd is not inherited by a child process created by
# os.spawnl(): get_osfhandle() and dup() must fail with EBADF.
code = textwrap.dedent(f"""
import errno
import os
Expand All @@ -4514,6 +4516,7 @@ def test_pipe_spawnl(self):
except OSError as exc:
if exc.errno != errno.EBADF:
raise
# get_osfhandle(fd) failed with EBADF as expected
else:
raise Exception("get_osfhandle() must fail")
Expand All @@ -4522,6 +4525,7 @@ def test_pipe_spawnl(self):
except OSError as exc:
if exc.errno != errno.EBADF:
raise
# os.dup(fd) failed with EBADF as expected
else:
os.close(fd3)
raise Exception("dup must fail")
Expand Down

0 comments on commit dcdc5ff

Please sign in to comment.