gh-127371 Avoid unbounded growth SpooledTempfile.writelines#127372
gh-127371 Avoid unbounded growth SpooledTempfile.writelines#127372serhiy-storchaka merged 9 commits intopython:mainfrom
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 |
tomasr8
left a comment
There was a problem hiding this comment.
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 |
|
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 <10796600+picnixz@users.noreply.github.com>
|
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. |
|
Just merge main by hitting the "Update branch" button. We generally want to avoid force pushes because it makes incremental reviews much harder. We anyway squash-merge at the end, so there's no need for a clean commit history on the PR in general. What's important is to make reviews simpler and easier to follow. Note that hitting "Update branch" only merges main with a single commit so it's fine. |
|
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:
|
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM.
Small suggestion to reduce overhead and avoid behavior change for weird iterators.
|
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 <bert@bertptrs.nl>
|
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 <bert@bertptrs.nl>
|
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