[Python-checkins] r76572 - in python/branches/py3k: Lib/copy.py Lib/test/test_copy.py Misc/ACKS Misc/NEWS
antoine.pitrou
python-checkins at python.org
Sat Nov 28 16:58:28 CET 2009
Author: antoine.pitrou
Date: Sat Nov 28 16:58:27 2009
New Revision: 76572
Log:
Merged revisions 76571 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r76571 | antoine.pitrou | 2009-11-28 16:55:58 +0100 (sam., 28 nov. 2009) | 3 lines
Issue #1515: Enable use of deepcopy() with instance methods. Patch by Robert Collins.
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/copy.py
python/branches/py3k/Lib/test/test_copy.py
python/branches/py3k/Misc/ACKS
python/branches/py3k/Misc/NEWS
Modified: python/branches/py3k/Lib/copy.py
==============================================================================
--- python/branches/py3k/Lib/copy.py (original)
+++ python/branches/py3k/Lib/copy.py Sat Nov 28 16:58:27 2009
@@ -238,6 +238,10 @@
if PyStringMap is not None:
d[PyStringMap] = _deepcopy_dict
+def _deepcopy_method(x, memo): # Copy instance methods
+ return type(x)(x.__func__, deepcopy(x.__self__, memo))
+_deepcopy_dispatch[types.MethodType] = _deepcopy_method
+
def _keep_alive(x, memo):
"""Keeps a reference to the object x in the memo.
Modified: python/branches/py3k/Lib/test/test_copy.py
==============================================================================
--- python/branches/py3k/Lib/test/test_copy.py (original)
+++ python/branches/py3k/Lib/test/test_copy.py Sat Nov 28 16:58:27 2009
@@ -677,6 +677,17 @@
del d
self.assertEqual(len(v), 1)
+ def test_deepcopy_bound_method(self):
+ class Foo(object):
+ def m(self):
+ pass
+ f = Foo()
+ f.b = f.m
+ g = copy.deepcopy(f)
+ self.assertEqual(g.m, g.b)
+ self.assertTrue(g.b.__self__ is g)
+ g.b()
+
def global_foo(x, y): return x+y
Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS (original)
+++ python/branches/py3k/Misc/ACKS Sat Nov 28 16:58:27 2009
@@ -144,6 +144,7 @@
Dave Cole
Benjamin Collar
Jeffery Collins
+Robert Collins
Paul Colomiets
Matt Conway
David M. Cooke
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sat Nov 28 16:58:27 2009
@@ -140,6 +140,9 @@
Library
-------
+- Issue #1515: Enable use of deepcopy() with instance methods. Patch by
+ Robert Collins.
+
- Issue #7403: logging: Fixed possible race condition in lock creation.
- Issue #6845: Add restart support for binary upload in ftplib. The
More information about the Python-checkins
mailing list