[pypy-issue] Issue #2075: pypy: Segmentation fault when printing unpickled generator (pypy/pypy)

Stefano Rivera issues-reply at bitbucket.org
Fri Jul 3 22:25:04 CEST 2015


New issue 2075: pypy: Segmentation fault when printing unpickled generator
https://bitbucket.org/pypy/pypy/issue/2075/pypy-segmentation-fault-when-printing

Stefano Rivera:

>From https://bugs.debian.org/786738:


```
#!python

import pickle

def f():
  yield 0

x = f()
x.next()
try:
  x.next()
except StopIteration:
  y = pickle.loads(pickle.dumps(x))
  print(y)
```

Segfaults on the print.

cPython refuses to pickle generators at all:

```
Traceback (most recent call last):
  File "test.py", line 11, in <module>
    y = pickle.loads(pickle.dumps(x))
  File "/usr/lib/python2.7/pickle.py", line 1374, in dumps
    Pickler(file, protocol).dump(obj)
  File "/usr/lib/python2.7/pickle.py", line 224, in dump
    self.save(obj)
  File "/usr/lib/python2.7/pickle.py", line 306, in save
    rv = reduce(self.proto)
  File "/usr/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle generator objects
```





More information about the pypy-issue mailing list