This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: TypeError raised when deepcopying built-in functions
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: loewis, oktaysafak
Priority: normal Keywords:

Created on 2003-05-30 19:59 by oktaysafak, last changed 2022-04-10 16:08 by admin. This issue is now closed.

Messages (2)
msg16211 - (view) Author: Oktay Safak (oktaysafak) Date: 2003-05-30 19:59
>>> import copy
>>> copy.deepcopy(max)

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in ?
    copy.deepcopy(max)
  File "C:\PYTHON23\lib\copy.py", line 205, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "C:\PYTHON23\lib\copy.py", line 336, in _reconstruct
    y = callable(*args)
  File "C:\PYTHON23\Lib\copy_reg.py", line 84, in __newobj__
    return cls.__new__(cls, *args)
TypeError: object.__new__(builtin_function_or_method) is not 
safe, use builtin_function_or_method.__new__()

Steven Taschuk's guess is that all things pickleable should be 
copyable since copy uses the same protocol as pickle. (He is 
not sure though) He demonstrates this idea with the following 
example:

>>> import pickle
>>> pickle.loads(pickle.dumps(max))
<built-in function max>

which succeeds unlike the first example.
msg16212 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-06-14 07:21
Logged In: YES 
user_id=21627

Thanks for the bugreport. This is now fixed in 

copy.py 1.42
test_copy.py 1.11
NEWS 1.782
copy.py 1.22.10.6
NEWS 1.337.2.4.2.88
History
Date User Action Args
2022-04-10 16:08:59adminsetgithub: 38570
2003-05-30 19:59:59oktaysafakcreate