-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
base: main
Are you sure you want to change the base?
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! :)
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