[pypy-issue] Issue #2293: Using codecs.open certian input causes a seek to crash (pypy/pypy)

Jean-Louis Fuchs issues-reply at bitbucket.org
Sat May 7 16:00:15 EDT 2016


New issue 2293: Using codecs.open certian input causes a seek to crash
https://bitbucket.org/pypy/pypy/issues/2293/using-codecsopen-certian-input-causes-a

Jean-Louis Fuchs:

This is based on a [chardet-testfile](https://github.com/chardet/chardet/blob/master/tests/EUC-KR/jely.pe.kr.xml)

I used code shrinker to create minimal example. To reproduce the problem:

1. Open the file with codecs.open
2. Read it with readlines
3. Then seek

Example code and the problemdata is attached.

This is the error:

```
#!bash
$> python pypybug.py
시작합니
Traceback (most recent call last):
  File "pypybug.py", line 6, in <module>
    f.seek(0)
  File "/home/ganwell/.pyenv/versions/pypy-5.1/lib-python/2.7/codecs.py", line 709, in seek
    self.writer.reset()
IOError: File not open for writing


```

And the testcode:


```
#!python
import codecs

with codecs.open("problemdata", "r", encoding="EUC-KR") as f:
    for x in f.readlines():
        print(x)
    f.seek(0)
```





More information about the pypy-issue mailing list