-
-
Notifications
You must be signed in to change notification settings - Fork 33k
gh-138813: Fix mutable default kwargs={} in multiprocessing BaseProcess and DummyProcess to use None #138814
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
gh-138813: Fix mutable default kwargs={} in multiprocessing BaseProcess and DummyProcess to use None #138814
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The core change looks good to me, but please add a test case to test_multiprocessing
.
d83c952
to
913e868
Compare
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
@ZeroIntensity, I’ve addressed your comment, please take another look. |
Misc/NEWS.d/next/Library/2025-09-13-15-31-09.gh-issue-138813.1k7qT6.rst
Outdated
Show resolved
Hide resolved
34a699f
to
1c9fd45
Compare
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the test case disappear?
Misc/NEWS.d/next/Library/2025-09-15-07-02-26.gh-issue-138813.yIju93.rst
Outdated
Show resolved
Hide resolved
d7b6b49
to
26da571
Compare
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Added the test in the latest commit. |
0489a60
to
820a48d
Compare
dfa3806
to
b6f292f
Compare
…eProcess and DummyProcess to use None (pythonGH-138814) * pythongh-138813: Default `BaseProcess` `kwargs` to `None` (pythonGH-138814) Set `BaseProcess.__init__(..., kwargs=None)` and initialize `kwargs` with `dict(kwargs) if kwargs else {}`. This avoids a shared mutable default and matches threading.Thread behavior. Co-authored-by: Dmitrii Chuprov <cheese@altlinux.org> * DummyProcess kwargs=None (which threading.Thread accepts properly) (cherry picked from commit 5a15e73) Co-authored-by: Denis Sergeev <newjimbatler00@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
…eProcess and DummyProcess to use None (pythonGH-138814) * pythongh-138813: Default `BaseProcess` `kwargs` to `None` (pythonGH-138814) Set `BaseProcess.__init__(..., kwargs=None)` and initialize `kwargs` with `dict(kwargs) if kwargs else {}`. This avoids a shared mutable default and matches threading.Thread behavior. Co-authored-by: Dmitrii Chuprov <cheese@altlinux.org> * DummyProcess kwargs=None (which threading.Thread accepts properly) (cherry picked from commit 5a15e73) Co-authored-by: Denis Sergeev <newjimbatler00@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
GH-139083 is a backport of this pull request to the 3.13 branch. |
GH-139084 is a backport of this pull request to the 3.14 branch. |
|
|
…seProcess and DummyProcess to use None (GH-138814) (#139084) gh-138813: Fix mutable default kwargs={} in multiprocessing BaseProcess and DummyProcess to use None (GH-138814) * gh-138813: Default `BaseProcess` `kwargs` to `None` (GH-138814) Set `BaseProcess.__init__(..., kwargs=None)` and initialize `kwargs` with `dict(kwargs) if kwargs else {}`. This avoids a shared mutable default and matches threading.Thread behavior. * DummyProcess kwargs=None (which threading.Thread accepts properly) (cherry picked from commit 5a15e73) Co-authored-by: Denis Sergeev <newjimbatler00@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Change the default value of the 'kwargs' parameter in DummyProcess.init() from {} to None to avoid mutable default argument issues. This makes DummyProcess consistent with threading.Thread and threading.Timer which already use this pattern.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reported by: Dmitrii Chuprov cheese@altlinux.org
multiprocessing.dummy.DummyProcess.__init__
#138813