Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-104231: make str(x) a str, bytes(x) a bytes #104247

Closed
wants to merge 2 commits into from

Conversation

sunmy2019
Copy link
Member

@sunmy2019 sunmy2019 commented May 6, 2023

@@ -1050,7 +1050,7 @@ class A:
def __bytes__(self):
return OtherBytesSubclass(b'abc')
self.assertEqual(bytes(A()), b'abc')
self.assertIs(type(bytes(A())), OtherBytesSubclass)
self.assertIs(type(bytes(A())), bytes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test being changed here was added in Python 3.4, in 1509580 (by @serhiy-storchaka). The commit was a fix for issue #68919.

(I haven't thought deeply about whether the change here is correct or desirable; just providing context.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was added to cover all paths, so the behavior change could not be unnoticed. I think that the new behavior is more correct.

But, for consistency with numeric types there should be a warning here. It may be a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@serhiy-storchaka Do you think we should go on with it, or wait for more opinions?

@mdickinson
Copy link
Member

Thanks for the ping! I don't have much of an opinion here, and I don't think I'm a good person for review.

@mdickinson mdickinson removed their request for review May 7, 2023 15:30
@sunmy2019
Copy link
Member Author

Closed in favour of #108814

@sunmy2019 sunmy2019 closed this Sep 2, 2023
@sunmy2019 sunmy2019 deleted the gh-104231-option1 branch September 2, 2023 14:27
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.

4 participants