Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tighten str subclass conversion regression
Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
  • Loading branch information
Copilot and youknowone committed Mar 28, 2026
commit 514053415cbe168fb776db83efac2d61e690a1f7
7 changes: 7 additions & 0 deletions Lib/test/test_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,10 @@ def __str__(self):
self.assertTypedEqual(StrSubclass(StrWithStr(OtherStrSubclass('abc'))),
StrSubclass('abc'))

str_value = StrSubclass('abc')
self.assertIs(str(WithStr(str_value)), str_value)
self.assertIs(str(StrWithStr(str_value)), str_value)

self.assertTypedEqual(str(WithRepr('<abc>')), '<abc>')
self.assertTypedEqual(str(WithRepr(StrSubclass('<abc>'))), StrSubclass('<abc>'))
self.assertTypedEqual(StrSubclass(WithRepr('<abc>')), StrSubclass('<abc>'))
Expand All @@ -2448,6 +2452,9 @@ def __str__(self):
self.assertTypedEqual(StrSubclass(WithRepr(OtherStrSubclass('<abc>'))),
StrSubclass('<abc>'))

repr_value = StrSubclass('<abc>')
self.assertIs(str(WithRepr(repr_value)), repr_value)

def test_unicode_repr(self):
class s1:
def __repr__(self):
Expand Down