On 26.09.14 20:43, Christian Tismer wrote:
> Hi Wen,
>
> On 09.09.14 18:58, Wen Tao wrote:
>> I was able to pickle a generator in the stackless python 2.7 version,
>> the code I use is:
>>
>> def process():
>> yield 0
>> yield 1
>>
>> gen = process()
>> print(gen.send(None))
>> import pickle
>> print(pickle.dumps(gen))
>>
>> But in the stackless python 3.3 version (which I downloaded source
>> code and compiled in a Ubuntu 12.04 amd64 box), the code can not run.
>> The error message read was:
>>
>> 0
>> Traceback (most recent call last):
>>   File "test.py", line 8, in <module>
>>     print(pickle.dumps(gen))
>> _pickle.PicklingError: Can't pickle <class 'generator'>: attribute
>> lookup builtins.generator failed
>>
>> Is this a feature? Or deserve a bug fix?
>>
>
> This does of course deserve a bug fix.
> Looking into that ...

First result on Python 3.4:

If you disable the fast pickling mode, then it works in 3.4.
In line 1590 of pickle.py you can change the _pickle name to something
else, then the interpreted version of pickle will be used.

Obviously, something inhibits our machinery from doing its work.
On 2.7, it both works with pickle and cPickle.

So the general answer for now:
It should work, some builtin check prevents that, and we are missing
a test for that as well.

Will work on that, later. Filing a bug.

cheers - Chris

-- 
Christian Tismer             :^)   tis...@stackless.com
Software Consulting          :     http://www.stackless.com/
Karl-Liebknecht-Str. 121     :     http://www.pydica.net/
14482 Potsdam                :     GPG key -> 0xFB7BEE0E
phone +49 173 24 18 776  fax +49 (30) 700143-0023

_______________________________________________
Stackless mailing list
Stackless@stackless.com
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to