Skip to content

Commit 1c9fd45

Browse files
zeff-irDmitrii Chuprov
andcommitted
gh-138813: Default BaseProcess kwargs to None (#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 <[email protected]>
1 parent 4afa985 commit 1c9fd45

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/multiprocessing/process.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class BaseProcess(object):
7777
def _Popen(self):
7878
raise NotImplementedError
7979

80-
def __init__(self, group=None, target=None, name=None, args=(), kwargs={},
80+
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None,
8181
*, daemon=None):
8282
assert group is None, 'group argument must be None for now'
8383
count = next(_process_counter)
@@ -89,7 +89,7 @@ def __init__(self, group=None, target=None, name=None, args=(), kwargs={},
8989
self._closed = False
9090
self._target = target
9191
self._args = tuple(args)
92-
self._kwargs = dict(kwargs)
92+
self._kwargs = dict(kwargs) if kwargs else {}
9393
self._name = name or type(self).__name__ + '-' + \
9494
':'.join(str(i) for i in self._identity)
9595
if daemon is not None:

0 commit comments

Comments
 (0)