[IronPython] pickling python types

Ronnie Maor ronnie.maor at gmail.com
Mon Mar 22 12:53:25 CET 2010


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> wrote:

>  Hi,
>
> I tried running the following code and got an exception (Ipy 2.6 final):
>
>
>
> import clr
>
> from System import Int64
>
> pickle.dumps(clr.GetPythonType(Int64))
>
>
>
> *throws:*
>
> 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=2.0.0.0, 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.
>
> Thanks.
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100322/a21c7127/attachment.html>


More information about the Ironpython-users mailing list