There seems to be an inconsistency after readline due to the readahead. The attached test script (runs fine for CPython) reproduces the problem.
This could be related to issue1793, but since that issue was closed and am creating a new one.