mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Issue #2116: Weak references and weak dictionaries now support copy()ing and deepcopy()ing.
This commit is contained in:
parent
52035a04ab
commit
775fd66d7b
4 changed files with 116 additions and 1 deletions
|
@ -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 = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue