[issue5509] cPickle - module object has no attribute
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 defines the class Foo and pickles out a list of objects LoadFoo.py attempts to load the list of objects pickled by Foo I'm running Vista with "Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32" -- components: None files: Foo.py messages: 83759 nosy: ntroutman severity: normal status: open title: cPickle - module object has no attribute versions: Python 2.5 Added file: http://bugs.python.org/file13364/Foo.py ___ Python tracker <http://bugs.python.org/issue5509> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5509] cPickle - module object has no attribute
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 <http://bugs.python.org/issue5509> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5509] cPickle - module object has no attribute
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 module is trying to load the file. I think it would make more sense to actually include the module name, this means that an external module need simply ensure that the pickled class's module be imported with the correct name. -- ___ Python tracker <http://bugs.python.org/issue5509> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com