Skip to content

Commit 895ab33

Browse files
add test
1 parent 4bbf340 commit 895ab33

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Lib/test/test_descr.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5361,6 +5361,31 @@ def foo(self):
53615361
with self.assertRaisesRegex(NotImplementedError, "BAR"):
53625362
B().foo
53635363

5364+
def test_gh146587(self):
5365+
# See https://github.com/python/cpython/issues/146587
5366+
5367+
class A:
5368+
def __radd__(self, other): ...
5369+
5370+
class B(tuple): ...
5371+
5372+
self.assertIsNone(() + A())
5373+
self.assertIsNone(B() + A())
5374+
5375+
from typing import NamedTuple
5376+
5377+
class T(NamedTuple):
5378+
x: int
5379+
5380+
class A:
5381+
def __init__(self, *args):
5382+
self.lst = list(args)
5383+
def __radd__(self, other):
5384+
return A(*self.lst, other)
5385+
5386+
self.assertEqual(((1,)+A()).lst, [(1,)])
5387+
self.assertEqual((T(x=1)+A()).lst, [T(x=1)])
5388+
53645389

53655390
class DictProxyTests(unittest.TestCase):
53665391
def setUp(self):

0 commit comments

Comments
 (0)