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.
Created on 2008年06月08日 23:54 by alexandre.vassalotti, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| fix_namedtuple_pickling.patch | alexandre.vassalotti, 2008年06月08日 23:54 | |||
| Messages (4) | |||
|---|---|---|---|
| msg67853 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) | Date: 2008年06月08日 23:54 | |
There is currently a pickling bug in the namedtuple factory:
>>> from collections import namedtuple
>>> MemoRecord = namedtuple("MemoRecord", "key, msg")
>>> m = MemoRecord(1,"hello")
>>> import pickle
>>> pickle.loads(pickle.dumps(m))
Traceback (most recent call last):
...
TypeError: __new__() takes exactly 3 positional arguments (2 given)
The bug is due to the fact that classes created by namedtuple don't
handle the __new__ arguments in the same fashion as tuple.__new__. The
fix is simply to define __getnewargs__.
|
|||
| msg67854 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年06月09日 00:17 | |
Georg, this works fine in Py2.6 but not in Py3.0. Do you know what changed and whether other pickles will fail? |
|||
| msg67856 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年06月09日 00:24 | |
Found it. Py3.0 uses protocol 2 by default and that protocol has a different set of calls. |
|||
| msg67857 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年06月09日 01:30 | |
Fixed in r64047. Thanks for the submission. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:35 | admin | set | github: 47315 |
| 2008年06月09日 01:30:30 | rhettinger | set | status: open -> closed assignee: georg.brandl -> rhettinger messages: + msg67857 resolution: fixed keywords: patch, patch |
| 2008年06月09日 00:24:32 | rhettinger | set | keywords:
patch, patch messages: + msg67856 versions: + Python 2.6 |
| 2008年06月09日 00:17:37 | rhettinger | set | keywords:
patch, patch assignee: rhettinger -> georg.brandl messages: + msg67854 nosy: + georg.brandl versions: - Python 2.6 |
| 2008年06月09日 00:03:58 | rhettinger | set | priority: normal -> high keywords: patch, patch |
| 2008年06月08日 23:54:13 | alexandre.vassalotti | create | |