From: Pieter Eendebak Date: Fri, 29 Sep 2023 07:28:01 +0000 (+0200) Subject: gh-109868: Skip deepcopy memo check for empty memo (GH-109869) X-Git-Tag: v3.13.0a1~237 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05079d93e410fca1e41ed32e67c54d63cbd9b35b;p=thirdparty%2FPython%2Fcpython.git gh-109868: Skip deepcopy memo check for empty memo (GH-109869) --- diff --git a/Lib/copy.py b/Lib/copy.py index 6d7bb9a111b5..a69bc4e78c20 100644 --- a/Lib/copy.py +++ b/Lib/copy.py @@ -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)