New submission from Alexandre Vassalotti <[EMAIL PROTECTED]>:

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

----------
assignee: rhettinger
components: Library (Lib)
files: fix_namedtuple_pickling.patch
keywords: patch, patch
messages: 67853
nosy: alexandre.vassalotti, rhettinger
priority: normal
severity: normal
status: open
title: Fix pickling bug of collections.namedtuple
type: behavior
versions: Python 2.6, Python 3.0
Added file: http://bugs.python.org/file10558/fix_namedtuple_pickling.patch

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3065>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to