Copy builtin functions as atomic. Fixes #746304. Will backport to 2.2.

This commit is contained in:
Martin v. Löwis 2003-06-14 07:10:06 +00:00
parent c1aa8dceb7
commit ba8f5ff76c
3 changed files with 5 additions and 2 deletions

View file

@ -120,6 +120,7 @@ def _copy_atomic(x):
d[types.TypeType] = _copy_atomic
d[types.XRangeType] = _copy_atomic
d[types.ClassType] = _copy_atomic
d[types.BuiltinFunctionType] = _copy_atomic
def _copy_list(x):
return x[:]
@ -233,6 +234,7 @@ def _deepcopy_atomic(x, memo):
d[types.TypeType] = _deepcopy_atomic
d[types.XRangeType] = _deepcopy_atomic
d[types.ClassType] = _deepcopy_atomic
d[types.BuiltinFunctionType] = _deepcopy_atomic
def _deepcopy_list(x, memo):
y = []

View file

@ -84,7 +84,7 @@ def f():
pass
tests = [None, 42, 2L**100, 3.14, True, False, 1j,
"hello", u"hello\u1234", f.func_code,
NewStyle, xrange(10), Classic]
NewStyle, xrange(10), Classic, max]
for x in tests:
self.assert_(copy.copy(x) is x, `x`)
@ -257,7 +257,7 @@ def f():
pass
tests = [None, 42, 2L**100, 3.14, True, False, 1j,
"hello", u"hello\u1234", f.func_code,
NewStyle, xrange(10), Classic]
NewStyle, xrange(10), Classic, max]
for x in tests:
self.assert_(copy.deepcopy(x) is x, `x`)

View file

@ -83,6 +83,7 @@ Library
- copy.py: applied SF patch 707900, fixing bug 702858, by Steven
Taschuk. Copying a new-style class that had a reference to itself
didn't work. (The same thing worked fine for old-style classes.)
Builtin functions are now treated as atomic, fixing bug #746304.
- difflib.py has two new functions: context_diff() and unified_diff().