Skip to content

bpo-43142: Do not add duplicate FDs to list in duplicate_for_child() #24461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/multiprocessing/popen_spawn_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def __init__(self, process_obj):
super().__init__(process_obj)

def duplicate_for_child(self, fd):
self._fds.append(fd)
# duplicates in self._fds would later lead to a ValueError
if fd not in self._fds:
self._fds.append(fd)
return fd

def _launch(self, process_obj):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not add duplicate FDs to list in duplicate_for_child() in order to avoid ValueError: bad value(s) in fds_to_keep