Skip to content

gh-160427: Return None from TextIOWrapper.buffer when detached - #160802

Open
cmaloney wants to merge 1 commit into
python:mainfrom
cmaloney:gh-160427-textio-buffer-none
Open

cmaloney wants to merge 1 commit into
python:mainfrom
cmaloney:gh-160427-textio-buffer-none

Conversation

@cmaloney

@cmaloney cmaloney commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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.

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.
@cmaloney

Copy link
Copy Markdown
Contributor Author

cc: @kumaraditya303 , @vstinner : This attribute changed from returning None when unset to raising a ValueError. That was backported to stable branches breaking backwards compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hasattr(stream, "buffer") fails with ValueError if buffer is detached

1 participant