Did some digging in the call stack:
pickle.py line 299:
if reduce
rv = reduce(obj)
at some point (third recursion):
obj = <module '__main__' from
'd:\Documents\Code\python\floware\toolshed\tests\stackless_error_test.py'>
and in Wing debugger:
rv = (<built-in function wingdb_import_hook>, ('__main__', (), (), ('',))),
which cannot be found
while in PyDev debugger:
rv = (<built-in function __import__>, ('__main__', (), (), ('',))), which
is found i guess
So that's where it finds 'wingdb_import_hook', but i think reduce(obj) is a
C extension, because i cannot step into.
On Thu, Oct 24, 2013 at 8:37 PM, lars van Gemerden <[email protected]>wrote:
> 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 <
> [email protected]> wrote:
>
>>
>> > -----Original Message-----
>> > From: [email protected] [mailto:stackless-
>> > [email protected]] On Behalf Of John Ehresman
>> > Sent: 23. október 2013 15:06
>> > To: [email protected]
>> > 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
>> [email protected]
>> http://www.stackless.com/mailman/listinfo/stackless
>>
>
>
>
> --
> ====================================
> Lars van Gemerden
> [email protected]
> +31 6 26 88 55 39
> ====================================
>
--
====================================
Lars van Gemerden
[email protected]
+31 6 26 88 55 39
====================================
_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless