Skip to content

Commit 5140534

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

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
@@ -2440,6 +2440,10 @@ def __str__(self):
24402440
self.assertTypedEqual(StrSubclass(StrWithStr(OtherStrSubclass('abc'))),
24412441
StrSubclass('abc'))
24422442

2443+
str_value = StrSubclass('abc')
2444+
self.assertIs(str(WithStr(str_value)), str_value)
2445+
self.assertIs(str(StrWithStr(str_value)), str_value)
2446+
24432447
self.assertTypedEqual(str(WithRepr('<abc>')), '<abc>')
24442448
self.assertTypedEqual(str(WithRepr(StrSubclass('<abc>'))), StrSubclass('<abc>'))
24452449
self.assertTypedEqual(StrSubclass(WithRepr('<abc>')), StrSubclass('<abc>'))
@@ -2448,6 +2452,9 @@ def __str__(self):
24482452
self.assertTypedEqual(StrSubclass(WithRepr(OtherStrSubclass('<abc>'))),
24492453
StrSubclass('<abc>'))
24502454

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

0 commit comments

Comments
 (0)