From ba8f5ff76c8e0aa7767a9a7c59f25a2db95f5d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sat, 14 Jun 2003 07:10:06 +0000 Subject: Copy builtin functions as atomic. Fixes #746304. Will backport to 2.2. --- Lib/copy.py | 2 ++ Lib/test/test_copy.py | 4 ++-- Misc/NEWS | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/copy.py b/Lib/copy.py index 02aa46b..31adfd3 100644 --- a/Lib/copy.py +++ b/Lib/copy.py @@ -120,6 +120,7 @@ except AttributeError: 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 @@ except AttributeError: 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 = [] diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py index a53f988..3d44304 100644 --- a/Lib/test/test_copy.py +++ b/Lib/test/test_copy.py @@ -84,7 +84,7 @@ class TestCopy(unittest.TestCase): 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 @@ class TestCopy(unittest.TestCase): 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`) diff --git a/Misc/NEWS b/Misc/NEWS index d4a8058..07a5b57 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -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(). -- cgit v0.12