According to issue 3150 https://foss.heptapod.net/pypy/pypy/-/issues/3150, this is on purpose, and brings us into feature compatibility with CPython:

Python 3.8.6 | packaged by conda-forge | (default, Oct  7 2020, 19:08:05)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> def f():
...     yield 10
...
>>> gen = f()
>>> pickle.dumps(gen)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot pickle 'generator' object

I guess we could improve the error message to be more helpful. Do you have a concrete use case for this?

Matti.


On 12/11/20 1:55 PM, Ioannis Foufoulas wrote:
Hi,
While in PyPy was possible to pickle a generator function and resume after 
unpicking this does not happen with PyPy3:

File "/snap/pypy3/72/lib-python/3/pickle.py", line 942, in save_global
     (obj, module_name, name))
pickle.PicklingError: Can't pickle <class 'generator'>: it's not found as 
builtins.generator

Is this a bug or this feature is removed in PyPy3?

Thanks,
Yannis
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to