]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109868: Skip deepcopy memo check for empty memo (GH-109869)
authorPieter Eendebak <pieter.eendebak@gmail.com>
Fri, 29 Sep 2023 07:28:01 +0000 (09:28 +0200)
committerGitHub <noreply@github.com>
Fri, 29 Sep 2023 07:28:01 +0000 (10:28 +0300)
Lib/copy.py

index 6d7bb9a111b5b48f41c475e4d9718472995b835b..a69bc4e78c20b308386fa896b6056997cfebdec9 100644 (file)
@@ -121,13 +121,13 @@ def deepcopy(x, memo=None, _nil=[]):
     See the module's __doc__ string for more info.
     """
 
+    d = id(x)
     if memo is None:
         memo = {}
-
-    d = id(x)
-    y = memo.get(d, _nil)
-    if y is not _nil:
-        return y
+    else:
+        y = memo.get(d, _nil)
+        if y is not _nil:
+            return y
 
     cls = type(x)