You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I confirmed the problem on default (3.6) and verified that it works as expected using utf-8 instead of iso-2022-jp.
The code in the above message should be converted into a unittest, and related codecs should be checked as well.
The problem is probably in Modules/cjkcodecs/_codecs_iso2022.c
Here is Martin's message as a unit test. It checks utf-8 and the iso-2022 family except iso-2022-cn and iso-2022-cn-ext because they are not supported. The errors occur with all iso-2022 charsets.
After thinking about bpo-26158, I realize the seek() magic numbers don’t store any _encoder_ state, only _decoder_ state. That would explain the first bug (write, seek, then read). Though for this codec I suspect the decoder state is not recorded either, hence the bug with tell().
Personally I don’t care much for seeking text files. But if someone wanted to fix the second bug, that might require fixing the incremental decoder’s getstate() implementation.
Activity
vadmium commentedon Dec 15, 2015
ezio-melotti commentedon Dec 28, 2015
I confirmed the problem on default (3.6) and verified that it works as expected using utf-8 instead of iso-2022-jp.
The code in the above message should be converted into a unittest, and related codecs should be checked as well.
The problem is probably in Modules/cjkcodecs/_codecs_iso2022.c
johnwalker commentedon Dec 30, 2015
Here is Martin's message as a unit test. It checks utf-8 and the iso-2022 family except iso-2022-cn and iso-2022-cn-ext because they are not supported. The errors occur with all iso-2022 charsets.
vadmium commentedon Jan 20, 2016
After thinking about bpo-26158, I realize the seek() magic numbers don’t store any _encoder_ state, only _decoder_ state. That would explain the first bug (write, seek, then read). Though for this codec I suspect the decoder state is not recorded either, hence the bug with tell().
Personally I don’t care much for seeking text files. But if someone wanted to fix the second bug, that might require fixing the incremental decoder’s getstate() implementation.