File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff 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
53655390class DictProxyTests (unittest .TestCase ):
53665391 def setUp (self ):
You can’t perform that action at this time.
0 commit comments