Repository navigation
gh-160427: Return None from TextIOWrapper.buffer when detached - #160802
Conversation
pythongh-154523 turned the buffer member descriptor into a getter that raises ValueError when the buffer is NULL, and the backport shipped in 3.14.9 and 3.15.1. That made hasattr(stream, "buffer") raise after detach(). Restore the old member descriptor result (None) while keeping the critical section.
|
cc: @kumaraditya303 , @vstinner : This attribute changed from returning |
|
Thanks @cmaloney for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
Sorry, @cmaloney, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
GH-161449 is a backport of this pull request to the 3.15 branch. |
|
GH-161450 is a backport of this pull request to the 3.14 branch. |
…GH-160802) (#161449) gh-154523 turned the buffer member descriptor into a getter that raises ValueError when the buffer is NULL, and the backport shipped in 3.14.9 and 3.15.1. That made hasattr(stream, "buffer") raise after detach(). Restore the old member descriptor result (None) while keeping the critical section. (cherry picked from commit 3422197) Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
…GH-160802) (#161450) gh-154523 turned the buffer member descriptor into a getter that raises ValueError when the buffer is NULL, and the backport shipped in 3.14.9 and 3.15.1. That made hasattr(stream, "buffer") raise after detach(). Restore the old member descriptor result (None) while keeping the critical section. (cherry picked from commit 3422197)
vstinner
left a comment
There was a problem hiding this comment.
Post-merge review.
Ooops, it's not good to change io module behavior in bugfix releases. Well, it happens, it should now be fixed as any other bug/regression. At least, we do now have a test checking for the expected behavior.
LGTM. _io_TextIOWrapper_buffer_get_impl() code is safe on Free Threading since it uses a critical section.
gh-154523 turned the buffer member descriptor into a getter that raises ValueError when the buffer is NULL, and the backport shipped in 3.14.9 and 3.15.1. That changed the behavior of
hasattr(stream, "buffer")to raise after.detach(). Restore the old member descriptor result (None) while keeping the critical section for free-threaded safety.hasattr(stream, "buffer")fails with ValueError if buffer is detached #160427