File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -769,6 +769,7 @@ def test_or_type_repr(self):
769769 assert repr (int | None ) == "int | None"
770770 assert repr (int | type (None )) == "int | None"
771771 assert repr (int | typing .GenericAlias (list , int )) == "int | list[int]"
772+ assert repr (int | typing .TypeVar ('T' )) == "int | ~T"
772773
773774 def test_or_type_operator_with_genericalias (self ):
774775 a = list [int ]
@@ -805,13 +806,18 @@ def __eq__(self, other):
805806 issubclass (int , type_ )
806807
807808 def test_or_type_operator_with_bad_module (self ):
808- class TypeVar :
809+ class BadMeta (type ):
810+ __qualname__ = 'TypeVar'
809811 @property
810812 def __module__ (self ):
811813 1 / 0
814+ TypeVar = BadMeta ('TypeVar' , (), {})
815+ _SpecialForm = BadMeta ('_SpecialForm' , (), {})
812816 # Crashes in Issue44483
813817 with self .assertRaises (ZeroDivisionError ):
814818 str | TypeVar ()
819+ with self .assertRaises (ZeroDivisionError ):
820+ str | _SpecialForm ()
815821
816822 @cpython_only
817823 def test_or_type_operator_reference_cycle (self ):
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ is_typing_name(PyObject *obj, char *name)
127127 if (strcmp (type -> tp_name , name ) != 0 ) {
128128 return 0 ;
129129 }
130- return is_typing_module (obj );
130+ return is_typing_module (( PyObject * ) type );
131131}
132132
133133static PyObject *
You can’t perform that action at this time.
0 commit comments