-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-25862: Fix an assertion failure in io.TextIOWrapper.tell(). #3918
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
bpo-25862: Fix an assertion failure in io.TextIOWrapper.tell(). #3918
Conversation
33e3a5e
to
5fd8540
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR @ZackerySpytz. It fixes the original case. But there are other similar cases, and it would be nice to fix them in a single issue. It is enough to fix tell()
after write()
. Other cases look less rare and more complex. They can be fixed in separate PRs.
Lib/test/test_io.py
Outdated
@@ -3549,6 +3549,13 @@ def test_reconfigure_newline(self): | |||
expected = 'linesep' + os.linesep + 'LF\nLF\nCR\rCRLF\r\n' | |||
self.assertEqual(txt.detach().getvalue().decode('ascii'), expected) | |||
|
|||
def test_issue25862(self): | |||
# tell() shouldn't cause an assertion failure if called after read(). | |||
t = self.TextIOWrapper(self.BytesIO(b'test')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The encoding depends on the environment. This can affect the test. It is better to specify the encoding explicitly.
eac030f
to
d00fa36
Compare
d00fa36
to
3066cf8
Compare
Thanks @ZackerySpytz for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7. |
…GH-3918) (cherry picked from commit 23db935) Co-authored-by: Zackery Spytz <[email protected]>
GH-8007 is a backport of this pull request to the 3.7 branch. |
Sorry, @ZackerySpytz and @serhiy-storchaka, I could not cleanly backport this to |
Sorry, @ZackerySpytz and @serhiy-storchaka, I could not cleanly backport this to |
(cherry picked from commit 23db935) Co-authored-by: Zackery Spytz <[email protected]>
…ythonGH-3918). (cherry picked from commit 23db935) Co-authored-by: Zackery Spytz <[email protected]>
GH-8012 is a backport of this pull request to the 3.6 branch. |
…H-3918). (GH-8012) (cherry picked from commit 23db935) Co-authored-by: Zackery Spytz <[email protected]>
…ythonGH-3918). (cherry picked from commit 23db935) Co-authored-by: Zackery Spytz <[email protected]>
GH-8013 is a backport of this pull request to the 2.7 branch. |
…H-3918). (GH-8013) (cherry picked from commit 23db935) Co-authored-by: Zackery Spytz <[email protected]>
Calling
read()
can callPy_CLEAR(self->snapshot)
, butself->decoded_chars
is not set toNULL
in this case. This can cause an assertion failure intell()
.https://bugs.python.org/issue25862