-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-127371 Avoid unbounded growth SpooledTempfile.writelines #127372
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
gh-127371 Avoid unbounded growth SpooledTempfile.writelines #127372
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
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.
Thanks! I think this also needs a test :)
Misc/NEWS.d/next/Security/2024-11-28-20-29-21.gh-issue-127371.PeEhUd.rst
Outdated
Show resolved
Hide resolved
751c78f
to
b4dd28c
Compare
Thanks for the review! Addressed your comments and added a simple test. |
Thanks! Please avoid force pushing if possible, it makes it more difficult to see what the latest changes are 🙂 As the bot said, you'll also need to sign the Contributor License Agreement. |
Misc/NEWS.d/next/Security/2024-11-28-20-29-21.gh-issue-127371.PeEhUd.rst
Outdated
Show resolved
Hide resolved
I think it should be good like this, then. Note: I'm aware of the failing CI test for my news entry, but I don't know what's wrong about the way I linked the method. Could you help me with that? |
I think that's because the method is not documented so there is nothing to link to. IIRC
|
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.
LGTM! :)
Hey, it's been a while, is there anything I need to do to get a core review, or any changes I could make to make it easier to merge? |
Serhiy might have time :) cc @serhiy-storchaka |
Hey, it's been another month and a bit, could this still get a review? |
Misc/NEWS.d/next/Security/2024-11-28-20-29-21.gh-issue-127371.PeEhUd.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Bénédikt Tran <[email protected]>
You should merge main into this branch because of some new CI configuration (just hit the "Update branch" button) |
@picnixz do you prefer I rebase it (squashing some fixups along the way) or merge main into this branch? I was previously requested to not force-push, but merging main will also make the history unclear. |
FTR, there are situations when force-pushing is necessary. I've listed them in some PR, but I'll list them here again:
In general, only the two first situations warrant a force-push. I force-push a lot in a draft PR if no review has been made yet, but otherwise, once a review was done, I generally avoid force-pushing. I however rebase a lot my local PRs before they're submitted upstream. |
Thank you for explaining. My employer and other projects I work on have a radically different view on the same, so I'm just trying to understand how the commit culture is here and adhere to it. Please don't take my questions as criticism. |
No worries. It's always good to ask when one's unsure! Every project has different guidelines. We should probably expand the https://devguide.python.org/ to indicate when force-pushing is allowed and when/why it's not good otherwise. EDIT: we do have a small note but it's kind of burried:
|
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.
LGTM.
Small suggestion to reduce overhead and avoid behavior change for weird iterators.
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.
LGTM.
Thanks @bertptrs for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Thanks @bertptrs for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
…thonGH-127372) (cherry picked from commit cb67b44) Co-authored-by: Bert Peters <[email protected]>
GH-130885 is a backport of this pull request to the 3.12 branch. |
…thonGH-127372) (cherry picked from commit cb67b44) Co-authored-by: Bert Peters <[email protected]>
GH-130886 is a backport of this pull request to the 3.13 branch. |
|
By checking after every line whether we've rolled over, we ensure that internal buffer doesn't grow too far beyond the expected bounds (at most one line).
To avoid a performance regression, I opted to introduce several fast-paths: if the SpooledTemplFile has already been rolled over to disk, or if it never will because the size is unbounded, the implementation delegates directly to the underlying file object.
SpooledTemporaryFile.writelines()
#127371