Ahh, that sounds like a bad bug, but I think I know what's causing it - we're 
hitting the new.NET serialization support because __reduce_ex__ is now defined 
for you :)  Can you add an override that dispatches __reduce_ex__ to the object 
version, eg:

def __reduce_ex__(self, *args):
    return object.__reduce_ex__(self, *args)

We should probably do that automatically for user-defined instances which 
should be easy to do if this works for you.

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Serge
Sent: Monday, October 06, 2008 7:36 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Serializing IronPython classes

Thanks for the heads up, however trying to use cPickle, I still get the error 
saying that the child class is not marked as serializable..?
On 10/7/08, Dino Viehland <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>> wrote:

I would strongly encourage you to use cPickle or pickle instead of .NET 
serialization.  In 2.0 all .NET serializable types can also be pickled - they 
define __reduce_ex__ which handles this.



First off we should be setting the serializable bit on subclasses that are 
serializable - that's just a bug that we're not doing that.  But once we've 
done that the problem w/ .NET serialization is that ultimately we need a static 
method or type that we can point at that does the deserialization.  For a user 
defined type in Python we will need to be able to deserialize the type, the 
module the type lives in, and presumably even the ScriptRuntime which holds the 
module.  Pickle handles this by serializing the module & type name but w/o a 
ScriptRuntime we couldn't even get at that.  We might have been able to require 
a ScriptRuntime to be smuggled in the StreamingContext but it's not clear that 
it would work well.



So if you really want .NET serialization we can fix the bug - but you'll need 
to implement ISerializable and figure out some way to deal getting the class, 
module, and runtime information saved/restored yourself.



From: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> [mailto:[EMAIL 
PROTECTED]<mailto:[EMAIL PROTECTED]>] On Behalf Of Serge
Sent: Sunday, October 05, 2008 9:24 PM
To: users@lists.ironpython.com<mailto:users@lists.ironpython.com>
Subject: [IronPython] Serializing IronPython classes



I've run into problems with serialization. I have a serializable class defined 
in C# which gets extended from IP, however when I try to serialize a collection 
of both parent and child instances, I get an exception saying that the IP 
generated class is not marked as serializable.

With the lack of attributes, I am guessing I must do something else to enable 
serialization?

Regards, Serge.

_______________________________________________
Users mailing list
Users@lists.ironpython.com<mailto:Users@lists.ironpython.com>
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to