]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-153141: Fix mutable default argument in _SharedMemoryTracker.__init__ ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 5 Jul 2026 19:36:15 +0000 (21:36 +0200)
committerGitHub <noreply@github.com>
Sun, 5 Jul 2026 19:36:15 +0000 (12:36 -0700)
gh-153141: Fix mutable default argument in _SharedMemoryTracker.__init__ (GH-153142)

Fix default argument for segment_names in _SharedMemoryTracker constructor to not use a mutable list.
(cherry picked from commit d733b104d53e96584a6881d2772df65ad82573a0)

Co-authored-by: Vineet Kumar <108144301+whyvineet@users.noreply.github.com>
Lib/multiprocessing/managers.py

index ef791c2751688a7a0fc6759b1579fdf0c6559d2b..d145304300358e189d13876aa3b5ece7f5ff48a0 100644 (file)
@@ -1253,9 +1253,9 @@ if HAS_SHMEM:
     class _SharedMemoryTracker:
         "Manages one or more shared memory segments."
 
-        def __init__(self, name, segment_names=[]):
+        def __init__(self, name, segment_names=None):
             self.shared_memory_context_name = name
-            self.segment_names = segment_names
+            self.segment_names = [] if segment_names is None else segment_names
 
         def register_segment(self, segment_name):
             "Adds the supplied shared memory block name to tracker."