summaryrefslogtreecommitdiff
path: root/Lib/copy.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-05-15 16:54:52 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2009-05-15 16:54:52 +0000
commit775fd66d7bd74cdedef536ff4f8c134ba718678f (patch)
tree4f0f3a10518bb130dd9000fda2f1f5b2e4899d5f /Lib/copy.py
parent52035a04abc8b75c1481064639150e4089cd80c7 (diff)
downloadcpython-git-775fd66d7bd74cdedef536ff4f8c134ba718678f.tar.gz
Issue #2116: Weak references and weak dictionaries now support copy()ing and deepcopy()ing.
Diffstat (limited to 'Lib/copy.py')
-rw-r--r--Lib/copy.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index 3f2033f5ff..d3db93d08d 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -49,6 +49,7 @@ __getstate__() and __setstate__(). See the documentation for module
"""
import types
+import weakref
from copy_reg import dispatch_table
class Error(Exception):
@@ -102,7 +103,7 @@ def _copy_immutable(x):
for t in (type(None), int, long, float, bool, str, tuple,
frozenset, type, xrange, types.ClassType,
types.BuiltinFunctionType, type(Ellipsis),
- types.FunctionType):
+ types.FunctionType, weakref.ref):
d[t] = _copy_immutable
for name in ("ComplexType", "UnicodeType", "CodeType"):
t = getattr(types, name, None)
@@ -220,6 +221,7 @@ d[xrange] = _deepcopy_atomic
d[types.ClassType] = _deepcopy_atomic
d[types.BuiltinFunctionType] = _deepcopy_atomic
d[types.FunctionType] = _deepcopy_atomic
+d[weakref.ref] = _deepcopy_atomic
def _deepcopy_list(x, memo):
y = []