[Python-Dev] Pickling instances of nested classes (original) (raw)

Walter Dörwald walter at livinglogic.de
Fri Apr 1 21:29:44 CEST 2005


Samuele Pedroni wrote:

[...]

this should approximate that behavior better: [not tested] import sys .... def new(cls, name, bases, dic): sub = [x for x in dic.values() if isinstance(x,HierarchMeta)] newtype = type.new(cls, name, bases, dic) for x in sub: if not hasattr(x, 'outer') and getattr(sys.modules.get(x.module), x.name, None) is not x: x.outer = newtype return newtype ..... we don't set outer if a way to pickle the class is already there

This doesn't fix

class Foo: class Bar: pass

class Baz: Bar = Foo.Bar

both this should be a simple fix.

Bye, Walter Dörwald



More information about the Python-Dev mailing list