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: pickle fail to handle some class with __new__
Type: Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, yoch.melka
Priority: normal Keywords:

Created on 2013-07-04 14:03 by yoch.melka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug.py yoch.melka, 2013-07-04 14:03 test case
Messages (2)
msg192290 - (view) Author: yoch (yoch.melka) Date: 2013-07-04 14:03
Hi,

If some class objects have extra arguments in the __new__ constructor , pickle fail to serialize it.

Here the output of provided test-case :

Traceback (most recent call last):
  File "/home/yoch/bug.py", line 19, in <module>
    y = pickle.load(fp)
TypeError: __new__() missing 1 required positional argument: 'arg'

Best regards
msg192291 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2013-07-04 14:08
This is expected, your class must say how this __new__ constructor can be called.
http://docs.python.org/2/library/pickle.html#object.__getnewargs__
History
Date User Action Args
2022-04-11 14:57:47adminsetgithub: 62559
2013-07-04 14:08:15amaury.forgeotdarcsetstatus: open -> closed

nosy: + amaury.forgeotdarc
messages: + msg192291

resolution: works for me
2013-07-04 14:03:55yoch.melkacreate