[New-bugs-announce] [issue13520] Patch to make pickle aware of __qualname__

sbt report at bugs.python.org
Fri Dec 2 17:29:13 CET 2011

New submission from sbt <shibturn at gmail.com>:

The attached patch makes pickle use an object's __qualname__ attribute if __name__ does not work.

This makes nested classes, unbound instance methods and static methods picklable (assuming that __module__ and __qualname__ give the correct "address").

BTW, It would not be hard to make instance methods picklable (and, as a by-product, class methods) by giving instance methods a __reduce__ method equivalent to

  def __reduce__(self):
    return (getattr, (self.__self__, self.__name__))

Is there any reason not to make such a change?

files: pickle_qualname.patch
keywords: patch
messages: 148759
nosy: pitrou, sbt
priority: normal
severity: normal
status: open
title: Patch to make pickle aware of __qualname__
versions: Python 3.3
Added file: http://bugs.python.org/file23836/pickle_qualname.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list