| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix unbounded memory growth in :class:`io.TextIOWrapper` when repeatedly | ||
| writing an empty string. |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityGit seems to render the diff poorly, locally I see with -w (--ignore-all-space):
$ git show -w HEAD -- Modules/_io/textio.c commit c6b5163133619febd0fbe8c327e52399b1a54ffd (HEAD -> textio-acc, origin/textio-acc) Author: Stan Ulbrych <stan@python.org> Date: Sat Jun 20 21:16:54 2026 +0100 Fix unbounded memory growth from repeated empty writes to io.TextIOWrapper diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 24e08cec88f..5b2a20a30c2 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1820,6 +1820,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) } } + if (bytes_len > 0) { if (self->pending_bytes == NULL) { assert(self->pending_bytes_count == 0); self->pending_bytes = b; @@ -1846,6 +1847,11 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) } self->pending_bytes_count += bytes_len; + } + else { + Py_DECREF(b); + } + if (self->pending_bytes_count >= self->chunk_size || needflush || text_needflush) { if (_textiowrapper_writeflush(self) < 0)Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityyou can use ?w=1 on GitHub fwiw
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCool, thanks! But, it seems to be limited and unfortunately doesn’t support all options, ?ignore-all-space=1 didn't work for me.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.