[IronPython] pickling python types

Dino Viehland dinov at microsoft.com
Wed Mar 24 19:29:27 CET 2010

Yeah sorry for missing this and thanks for making sure we don't drop it.  I would agree that this is a bug.  I guess Int64.__module__ should really just be "System" and in general we shouldn't include the assembly name in the __module__ for built-in types.  That makes it slightly less useful to read but more useful for programmatic use.  Maybe we could add a new __assembly__ attribute to be more friendly to people.

If you don't open a bug on CodePlex I will.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ronnie Maor
Sent: Wednesday, March 24, 2010 11:20 AM
To: Discussion of IronPython
Subject: Re: [IronPython] pickling python types

Don't mean to nag, but it seems the original email was somehow overlooked.
We think it's a bug in 2.6.0
On Mon, Mar 22, 2010 at 1:53 PM, Ronnie Maor <ronnie.maor at gmail.com<mailto:ronnie.maor at gmail.com>> wrote:
Just a clarification - the GetPythonType below is superfluous
pickle.dumps(Int64) fails the same way

seems that all python types that aren't native (i.e. shadow an existing CLR type) fail that way.
Pickling the CLR type (RuntimeType) actually works.
On Mon, Mar 22, 2010 at 9:13 AM, Idan Zaltzberg <idan at cloudshare.com<mailto:idan at cloudshare.com>> wrote:
I tried running the following code and got an exception (Ipy 2.6 final):

import clr
from System import Int64

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\systems\3rd_party\IronPython\2.6\Lib\pickle.py", line 1366, in dumps
  File "C:\systems\3rd_party\IronPython\2.6\Lib\pickle.py", line 224, in dump
  File "C:\systems\3rd_party\IronPython\2.6\Lib\pickle.py", line 286, in save
  File "C:\systems\3rd_party\IronPython\2.6\Lib\pickle.py", line 746, in save_global
pickle.PicklingError: Can't pickle <type 'Int64'>: it's not found as System in mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089.Int64

Is this a bug?
Currently my workaround is to pickle the CS type and convert it to a python type after unpickling, please tell me if there is a better way.

Users mailing list
Users at lists.ironpython.com<mailto:Users at lists.ironpython.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100324/5427025a/attachment.html>

More information about the Ironpython-users mailing list