File tree 2 files changed +8
-2
lines changed
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):
769
769
assert repr (int | None ) == "int | None"
770
770
assert repr (int | type (None )) == "int | None"
771
771
assert repr (int | typing .GenericAlias (list , int )) == "int | list[int]"
772
+ assert repr (int | typing .TypeVar ('T' )) == "int | ~T"
772
773
773
774
def test_or_type_operator_with_genericalias (self ):
774
775
a = list [int ]
@@ -805,13 +806,18 @@ def __eq__(self, other):
805
806
issubclass (int , type_ )
806
807
807
808
def test_or_type_operator_with_bad_module (self ):
808
- class TypeVar :
809
+ class BadMeta (type ):
810
+ __qualname__ = 'TypeVar'
809
811
@property
810
812
def __module__ (self ):
811
813
1 / 0
814
+ TypeVar = BadMeta ('TypeVar' , (), {})
815
+ _SpecialForm = BadMeta ('_SpecialForm' , (), {})
812
816
# Crashes in Issue44483
813
817
with self .assertRaises (ZeroDivisionError ):
814
818
str | TypeVar ()
819
+ with self .assertRaises (ZeroDivisionError ):
820
+ str | _SpecialForm ()
815
821
816
822
@cpython_only
817
823
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)
127
127
if (strcmp (type -> tp_name , name ) != 0 ) {
128
128
return 0 ;
129
129
}
130
- return is_typing_module (obj );
130
+ return is_typing_module (( PyObject * ) type );
131
131
}
132
132
133
133
static PyObject *
You can’t perform that action at this time.
0 commit comments