[issue5509] cPickle - module object has no attribute

2009-12-05 Thread rb
rb added the comment: I've just been stung by this. I've noticed that this seems to apply to both cPickle and pickle. Even worse, it causes different behaviour when a program is run under pdb because __main__ is suddenly pdb rather than the program itself. So, in summary, neither pickle nor cPi

[issue5509] cPickle - module object has no attribute

2009-03-18 Thread Benjamin Peterson
Benjamin Peterson added the comment: Implementing this may be difficult (the module may not be on the search path when its run and there's no way to determine that). Also, it would break compatibility. Anyway, it's usually better to define classes that will be pickled in their own permanent modu

[issue5509] cPickle - module object has no attribute

2009-03-18 Thread Nathaniel Troutman
Nathaniel Troutman added the comment: I believe I've tracked down the problem. When you run a python module directly (ie "python Foo.py") any classes defined in the module have their '__module__' attribute set to '__main__'. Which means the pickle says the class is in '__main__' of whatever modu

[issue5509] cPickle - module object has no attribute

2009-03-18 Thread Nathaniel Troutman
Nathaniel Troutman added the comment: Why can I only attach one file at a time? -- Added file: http://bugs.python.org/file13365/LoadFoo.py ___ Python tracker ___

[issue5509] cPickle - module object has no attribute

2009-03-18 Thread Nathaniel Troutman
New submission from Nathaniel Troutman : If I define a class Foo in module A and in module A pickle out a list of Foo objects to 'foo.pkl', then in module B attempt to unpickle 'foo.pkl' I recieve the error "AttributeError: 'module' object has no attribute 'Foo'" Attached are: Foo.py which defin