Skip to content

Commit 0954aaa

Browse files
committed
Fix mutable default argument in multiprocessing.dummy.DummyProcess
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 <[email protected]> Signed-off-by: Denis Sergeev <[email protected]>
1 parent 4afa985 commit 0954aaa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/multiprocessing/dummy/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333

3434
class DummyProcess(threading.Thread):
3535

36-
def __init__(self, group=None, target=None, name=None, args=(), kwargs={}):
36+
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None):
37+
if kwargs is None:
38+
kwargs = {}
3739
threading.Thread.__init__(self, group, target, name, args, kwargs)
3840
self._pid = None
3941
self._children = weakref.WeakKeyDictionary()

0 commit comments

Comments
 (0)