My mistake, it was not an ironpython specific error, I have been able to reproduce the error in cPython as well. The error in cPython is:
KeyError: '[' While the error in iron python is: KeyError: [ Notice how the [ is between quotes in cPython, a small difference which threw me off. Thanks, Vineet -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Michael Foord Sent: Monday, April 13, 2009 11:29 AM To: Discussion of IronPython Subject: Re: [IronPython] Problem with pickle.load of user defined classes created from cPython 2.5. Vineet Jain (gmail) wrote: > > I'm trying to load pickled user defined classes from iron python. The > pickled object was created using cpython 2.5 on an ubuntu box. I can > load them fine with cpython 2.5 on a windows box. However when I load > them from ironpython I get the following incomplete stack trace: > > c:\trading\pytrade\modules\apiscripts\models>ipy test_pickle.py > > Traceback (most recent call last): > > File "test_pickle.py", line 20, in test_pickle.py > > File "test_pickle.py", line 13, in loadTrades > > File "c:\Program Files\IronPython 2.0.1\Lib\pickle.py", line 1370, in load > > File "c:\Program Files\IronPython 2.0.1\Lib\pickle.py", line 858, in load > > KeyError: [ > > Any ideas on how I can go about debugging this? Is pickle.load of user > defined classes from cPython supported? > That isn't enough information to diagnose the problem. The short answer is that yes, IronPython does support the unpickling of user defined classes created in CPython: C:\compile>python Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from test import Test >>> from pickle import dumps >>> t = Test() >>> open('instance.pkl', 'wb').write(dumps(t)) >>> C:\compile>"C:\Program Files (x86)\IronPython 2.0.1\ipy.exe" IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3074 Type "help", "copyright", "credits" or "license" for more information. >>> import test >>> from pickle import loads >>> >>> t = loads(open('instance.pkl').read()) >>> t <Test object at 0x000000000000002B> >>> In the example above the module test.py contains only: class Test(object): pass All the best, Michael > Thanks, > > Vineet > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > [email protected] > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
