X Tutup
Skip to content

Commit 008e4c6

Browse files
Copilotyouknowone
andcommitted
Tighten str subclass conversion regression
Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
1 parent a555ce4 commit 008e4c6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/test/test_str.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,10 @@ def __str__(self):
24412441
self.assertTypedEqual(StrSubclass(StrWithStr(OtherStrSubclass('abc'))),
24422442
StrSubclass('abc'))
24432443

2444+
str_value = StrSubclass('abc')
2445+
self.assertIs(str(WithStr(str_value)), str_value)
2446+
self.assertIs(str(StrWithStr(str_value)), str_value)
2447+
24442448
self.assertTypedEqual(str(WithRepr('<abc>')), '<abc>')
24452449
self.assertTypedEqual(str(WithRepr(StrSubclass('<abc>'))), StrSubclass('<abc>'))
24462450
self.assertTypedEqual(StrSubclass(WithRepr('<abc>')), StrSubclass('<abc>'))
@@ -2449,6 +2453,9 @@ def __str__(self):
24492453
self.assertTypedEqual(StrSubclass(WithRepr(OtherStrSubclass('<abc>'))),
24502454
StrSubclass('<abc>'))
24512455

2456+
repr_value = StrSubclass('<abc>')
2457+
self.assertIs(str(WithRepr(repr_value)), repr_value)
2458+
24522459
def test_unicode_repr(self):
24532460
class s1:
24542461
def __repr__(self):

0 commit comments

Comments
 (0)
X Tutup