[Stackless] Fwd: deepcopying (pickling) channels

lars van Gemerden lars at rational-it.com
Thu Oct 24 20:37:00 CEST 2013


made some more simple test cases (pickling Test1() and Test2() fails):

#-------------------------------------------------------------
import pickle

def func(): pass

class Test0(object):
    def __init__(self):
        self.func = func

class Test1(object):
    def __init__(self):
        self.func = lambda s: 0

class Test2(object):
    def __init__(self):
        self.func = self.func2
    def func2(self):
        pass


if __name__ == '__main__':

    s = pickle.dumps(Test0())
    t = pickle.loads(s)
    s = pickle.dumps(Test1()) #ERROR
    t = pickle.loads(s)
    s = pickle.dumps(Test2()) #ERROR
    t = pickle.loads(s)
    print 'done'
#-------------------------------------------------------------

all succeed in e.g. Idle.

Cheers, Lars



On Thu, Oct 24, 2013 at 4:52 PM, Kristján Valur Jónsson <
kristjan at ccpgames.com> wrote:

>
> > -----Original Message-----
> > From: stackless-bounces at stackless.com [mailto:stackless-
> > bounces at stackless.com] On Behalf Of John Ehresman
> > Sent: 23. október 2013 15:06
> > To: stackless at stackless.com
> > Subject: Re: [Stackless] Fwd: deepcopying (pickling) channels
> >
> > It does look like the __init__ saves a reference of self.func2 in
> self.func -- is
> > this what triggers the pickling of globals?
>
> Yes.  It is trying to pickle a bound function.
> But it is not pickling "globals".  save_global() means that it is trying
> to save an object by name.  It came across wingdb_import_hook during the
> process, and this function is not found where it says it is found.
> Now, where did it find the function?  We don't know.
> If you change pickle.py we might have a better idea.
>
> How about this:
>
> def save(self, obj):
>   try:
>     return self._save(obj)
>   except PickleError:
>     print "pickling obj: %r", obj
>     raise
>
> def _save(self, obj):
>   ... #rename old save to _save.
>
>
> This should give us more info.
>
> K
>
>
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless
>



-- 
====================================
Lars van Gemerden
lars at rational-it.com
+31 6 26 88 55 39
====================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20131024/634da3b4/attachment.html>


More information about the Stackless mailing list