This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients corona10, eric.smith, petr.viktorin, rhettinger, serhiy.storchaka, vstinner
Date 2022-03-28.16:23:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1648484609.42.0.455889590352.issue47143@roundup.psfhosted.org>
In-reply-to
Content
The same problem exists at the function level: see bpo-39805: "Copying functions doesn't actually copy them".

For example, copy.deepcopy(func) returns func unchanged if it's a function.

Example:
---
import copy

def make_closure():
    closure = []
    def append(value):
        closure.append(value)
    return append, closure

func, closure = make_closure()
func(1)
func2 = copy.deepcopy(func)
func2(2)
print(func2 is func)
print(closure)
---

Output:
---
True
[1, 2]
---
History
Date User Action Args
2022-03-28 16:23:29vstinnersetrecipients: + vstinner, rhettinger, eric.smith, petr.viktorin, serhiy.storchaka, corona10
2022-03-28 16:23:29vstinnersetmessageid: <1648484609.42.0.455889590352.issue47143@roundup.psfhosted.org>
2022-03-28 16:23:29vstinnerlinkissue47143 messages
2022-03-28 16:23:29vstinnercreate