Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError raised when deepcopying built-in functions #38570

Closed
oktaysafak mannequin opened this issue May 30, 2003 · 2 comments
Closed

TypeError raised when deepcopying built-in functions #38570

oktaysafak mannequin opened this issue May 30, 2003 · 2 comments
Labels
stdlib Python modules in the Lib dir

Comments

@oktaysafak
Copy link
Mannequin

oktaysafak mannequin commented May 30, 2003

BPO 746304
Nosy @loewis

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2003-06-14.07:21:12.000>
created_at = <Date 2003-05-30.19:59:59.000>
labels = ['library']
title = 'TypeError raised when deepcopying built-in functions'
updated_at = <Date 2003-06-14.07:21:12.000>
user = 'https://bugs.python.org/oktaysafak'

bugs.python.org fields:

activity = <Date 2003-06-14.07:21:12.000>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2003-05-30.19:59:59.000>
creator = 'oktaysafak'
dependencies = []
files = []
hgrepos = []
issue_num = 746304
keywords = []
message_count = 2.0
messages = ['16211', '16212']
nosy_count = 2.0
nosy_names = ['loewis', 'oktaysafak']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue746304'
versions = ['Python 2.3']

@oktaysafak
Copy link
Mannequin Author

oktaysafak mannequin commented May 30, 2003

>> 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.

@oktaysafak oktaysafak mannequin closed this as completed May 30, 2003
@oktaysafak oktaysafak mannequin added the stdlib Python modules in the Lib dir label May 30, 2003
@oktaysafak oktaysafak mannequin closed this as completed May 30, 2003
@oktaysafak oktaysafak mannequin added the stdlib Python modules in the Lib dir label May 30, 2003
@loewis
Copy link
Mannequin

loewis mannequin commented Jun 14, 2003

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

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

0 participants