[Python-Dev] Pickling instances of nested classes (original) (raw)
Walter Dörwald walter at livinglogic.de
Fri Apr 1 21:29:44 CEST 2005
- Previous message: [Python-Dev] Pickling instances of nested classes
- Next message: [Python-Dev] Unicode byte order mark decoding
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Pickling instances of nested classes
- Next message: [Python-Dev] Unicode byte order mark decoding
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]