-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextIOWrapper assertion failure after read() and SEEK_CUR #70049
Comments
Python 3.5.1+ (3.5:014e6f7d7c1a, Dec 14 2015, 11:20:58)
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from io import *
>>> text = TextIOWrapper(BytesIO(b"x"), "ascii")
>>> text.read(1)
'x'
>>> text.read()
''
>>> text.seek(0, SEEK_CUR)
python: ./Modules/_io/textio.c:2293: _io_TextIOWrapper_tell_impl: Assertion `self->decoded_chars == ((void *)0) || PyUnicode_GetLength(self->decoded_chars) == 0' failed.
Aborted (core dumped)
[Exit 134] May affect other versions; I haven’t looked. |
Similar case: text.read(1); text.write(b'x'); text.tell() And there may be crashes after setting self->snapshot to NULL due to the failure of Py_BuildValue(). |
The assertion failure can be also caused by setting self->snapshot to NULL when Py_BuildValue() fails due to lack of memory. It is very difficult to reproduce this. PR 8026 fixes this and other difficulty reproducible refcount bugs in the _io module. |
I haven’t confirmed, but it looks like the original change here broke bidirectional reading and writing with a single TextIOWrapper object; see bpo-35928. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: