Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-143689: Fix BufferedReader.read1 leaving object in reentrant state on error#143690
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
BufferedReader.read1() could leave the buffered object in areentrant (locked) state when an exception was raised whileallocating the output buffer.This change ensures the internal buffered lock is always releasedon error, keeping the object in a consistent state after failures.Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
cmaloney left a comment
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 for the patch! The fix looks correct. The NEWs entry and test don't quite match the preferred patterns in CPython, left some comments.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Library/2026-01-11-14-14-19.gh-issue-143689.fzHJ2W.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…zHJ2W.rstCo-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
hyongtao-code commentedJan 11, 2026
Thanks for the review and feedback — I’ve made the requested changes. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: sobolevn <mail@sobolevn.me>
f305804 toe36ddf6Comparecmaloney commentedJan 12, 2026
Please don't force-push to CPython PR branches:https://devguide.python.org/getting-started/pull-request-lifecycle/#don-t-force-push |
Uh oh!
There was an error while loading.Please reload this page.
hyongtao-code commentedJan 13, 2026
Sorry — I only realized afterward that using git revert to undo the previous commit would have been the better choice. |
vstinner left a comment
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. It seems like I introduced the regression in 3.15 with the commit4554486.
Uh oh!
There was an error while loading.Please reload this page.
cmaloney commentedJan 17, 2026
and I missed it in review but should have caught it :) |
375e372 intopython:mainUh oh!
There was an error while loading.Please reload this page.
vstinner commentedJan 19, 2026
Merged, thanks for the fix and the test. |
Uh oh!
There was an error while loading.Please reload this page.
BufferedReader.read1() could leave the buffered object in a
reentrant (locked) state when an exception was raised while
allocating the output buffer.
This change ensures the internal buffered lock is always released
on error, keeping the object in a consistent state after failures.