Skip to content

gh-104231: emit warning on __bytes__ and __str__ when returning strict subclass#108814

Closed
sunmy2019 wants to merge 2 commits into
python:mainfrom
sunmy2019:gh-104231
Closed

gh-104231: emit warning on __bytes__ and __str__ when returning strict subclass#108814
sunmy2019 wants to merge 2 commits into
python:mainfrom
sunmy2019:gh-104231

Conversation

@sunmy2019

@sunmy2019 sunmy2019 commented Sep 2, 2023

Copy link
Copy Markdown
Member

Returning strict subclasses at __str__ can cause unexpected behavior, since other parts of the VM have always assumed str(x) to be an instance of str, not its strict subclass. The same applies to the bytes(x).

Hence, we deprecated the ability to return strict subclasses of str/bytes at __str__/__bytes__, respectively.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 13, 2026
@sunmy2019 sunmy2019 closed this Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants