Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ba8f5ff

Browse files
committed
Copy builtin functions as atomic. Fixes #746304. Will backport to 2.2.
1 parent c1aa8dc commit ba8f5ff

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/copy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def _copy_atomic(x):
120120
d[types.TypeType] = _copy_atomic
121121
d[types.XRangeType] = _copy_atomic
122122
d[types.ClassType] = _copy_atomic
123+
d[types.BuiltinFunctionType] = _copy_atomic
123124

124125
def _copy_list(x):
125126
return x[:]
@@ -233,6 +234,7 @@ def _deepcopy_atomic(x, memo):
233234
d[types.TypeType] = _deepcopy_atomic
234235
d[types.XRangeType] = _deepcopy_atomic
235236
d[types.ClassType] = _deepcopy_atomic
237+
d[types.BuiltinFunctionType] = _deepcopy_atomic
236238

237239
def _deepcopy_list(x, memo):
238240
y = []

Lib/test/test_copy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def f():
8484
pass
8585
tests = [None, 42, 2L**100, 3.14, True, False, 1j,
8686
"hello", u"hello\u1234", f.func_code,
87-
NewStyle, xrange(10), Classic]
87+
NewStyle, xrange(10), Classic, max]
8888
for x in tests:
8989
self.assert_(copy.copy(x) is x, `x`)
9090

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

Misc/NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Library
8383
- copy.py: applied SF patch 707900, fixing bug 702858, by Steven
8484
Taschuk. Copying a new-style class that had a reference to itself
8585
didn't work. (The same thing worked fine for old-style classes.)
86+
Builtin functions are now treated as atomic, fixing bug #746304.
8687

8788
- difflib.py has two new functions: context_diff() and unified_diff().
8889

0 commit comments

Comments
 (0)