summaryrefslogtreecommitdiffstats
path: root/Lib/copy.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-11-28 15:55:58 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-11-28 15:55:58 (GMT)
commitd16f57bf4db4417c8d7a038a0b61bb24461cd64a (patch)
treef8b2164259eea6a713daf136a1fed649efd0f606 /Lib/copy.py
parentc63392c15205607610957e243824da9baba3f62f (diff)
downloadcpython-d16f57bf4db4417c8d7a038a0b61bb24461cd64a.zip
cpython-d16f57bf4db4417c8d7a038a0b61bb24461cd64a.tar.gz
cpython-d16f57bf4db4417c8d7a038a0b61bb24461cd64a.tar.bz2
Issue #1515: Enable use of deepcopy() with instance methods. Patch by Robert Collins.
Diffstat (limited to 'Lib/copy.py')
-rw-r--r--Lib/copy.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index d3db93d..bbbd5b3 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -260,6 +260,10 @@ d[dict] = _deepcopy_dict
if PyStringMap is not None:
d[PyStringMap] = _deepcopy_dict
+def _deepcopy_method(x, memo): # Copy instance methods
+ return type(x)(x.im_func, deepcopy(x.im_self, memo), x.im_class)
+_deepcopy_dispatch[types.MethodType] = _deepcopy_method
+
def _keep_alive(x, memo):
"""Keeps a reference to the object x in the memo.