[New-bugs-announce] [issue17941] namedtuple should support fully qualified name for more portable pickling

Eli Bendersky report at bugs.python.org
Thu May 9 05:46:56 CEST 2013


New submission from Eli Bendersky:

[this came up as part of the Enum discussions. Full details in this thread: http://mail.python.org/pipermail/python-dev/2013-May/126076.html]

namedtuple currently uses this code to obtain the __module__ for the class it creates dynamically so that pickling works:

  result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__')

This may not work correctly on all Python implementations, for example IronPython.

To support some way to pickle on all implementations, namedtuple should support a fully qualified name for the class: 

  Point = namedtuple('mymodule.Point', ['x', 'y'])

If the name is a qualified dotted name, it will be split and the first part becomes the __module__.

----------
components: Library (Lib)
messages: 188748
nosy: eli.bendersky, ncoghlan
priority: normal
severity: normal
stage: needs patch
status: open
title: namedtuple should support fully qualified name for more portable pickling
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17941>
_______________________________________


More information about the New-bugs-announce mailing list