Skip to content

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

Merged
cmaloney merged 1 commit into
python:mainfrom
cmaloney:gh-160427-textio-buffer-none
Nov 5, 2026
Merged

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

@cmaloney
cmaloney merged commit 3422197 into python:main Nov 5, 2026
62 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @cmaloney for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@cmaloney
cmaloney deleted the gh-160427-textio-buffer-none branch November 5, 2026 21:40
@miss-islington-app

Copy link
Copy Markdown

Sorry, @cmaloney, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 3422197f5481ac1b3134e2633332415a02959ba4 3.14

@bedevere-app

bedevere-app Bot commented Nov 5, 2026

Copy link
Copy Markdown

GH-161449 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 5, 2026
@bedevere-app

bedevere-app Bot commented Nov 5, 2026

Copy link
Copy Markdown

GH-161450 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 5, 2026
cmaloney added a commit that referenced this pull request Nov 5, 2026
…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>
cmaloney added a commit that referenced this pull request Nov 5, 2026
…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)
Sign up for free to 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.

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

1 participant