[issue33361] readline() + seek() on io.EncodedFile breaks next readline()

Diego Argueta report at bugs.python.org
Thu Apr 26 14:02:41 EDT 2018


Diego Argueta <diego.argueta at gmail.com> added the comment:

That's because the stream isn't transcoding, since UTF-8 is ASCII-compatible. Try using something not ASCII-compatible as the codec e.g. 'ibm500' and it'll give incorrect results.

```
b = io.BytesIO(u'a,b\r\n"asdf","jkl;"\r\n'.encode('ibm500'))
s = codecs.EncodedFile(b, 'ibm500')
```

```
Got header: '\x81k\x82\r%'
Skipping the header. '\x7f\x81\xa2\x84\x86\x7fk\x7f\x91\x92\x93^\x7f\r%'
Line 2: '\x81k\x82\r%'
Line 3: '\x7f\x81\xa2\x84\x86\x7fk\x7f\x91\x92\x93^\x7f\r%'
```

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33361>
_______________________________________


More information about the Python-bugs-list mailing list