Skip to content

Conversation

@hyongtao-code
Copy link
Contributor

@hyongtao-codehyongtao-code commented Jan 11, 2026

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.

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. Signed-off-by: Yongtao Huang <[email protected]>
Copy link
Contributor

@cmaloneycmaloney left a 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.

@hyongtao-code
Copy link
ContributorAuthor

The NEWs entry and test don't quite match the preferred patterns in CPython,

Thanks for the review and feedback — I’ve made the requested changes.

@cmaloney
Copy link
Contributor

Please don't force-push to CPython PR branches: https://devguide.python.org/getting-started/pull-request-lifecycle/#don-t-force-push

@hyongtao-code
Copy link
ContributorAuthor

don't force-push

Sorry — I only realized afterward that using git revert to undo the previous commit would have been the better choice.
Thanks for pointing that out; I’ll keep it in mind.

Copy link
Member

@vstinnervstinner left a 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 commit 4554486.

@cmaloney
Copy link
Contributor

and I missed it in review but should have caught it :)

@vstinnervstinner merged commit 375e372 into python:mainJan 19, 2026
50 checks passed
@vstinner
Copy link
Member

Merged, thanks for the fix and the test.

@hyongtao-codehyongtao-code deleted the dev-io-buffer branch January 19, 2026 15:50
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@hyongtao-code@cmaloney@vstinner@sobolevn