Skip to content

Commit aaeaa9c

Browse files
ilevkivskyigvanrossum
authored andcommitted
Avoid crash in test_typing in refleak hunting mode (#324)
See http://bugs.python.org/issue28649 (this is roughly fix-typing-test-v2.diff)
1 parent cf7ba5d commit aaeaa9c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

python2/test_typing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,10 @@ def test_extended_generic_rules_repr(self):
715715
'Callable[[], List[int]]')
716716

717717
def test_generic_forvard_ref(self):
718-
LLT = List[List['T']]
718+
LLT = List[List['CC']]
719+
class CC: pass
720+
self.assertEqual(typing._eval_type(LLT, globals(), locals()), List[List[CC]])
719721
T = TypeVar('T')
720-
self.assertEqual(typing._eval_type(LLT, globals(), locals()), List[List[T]])
721722
TTE = Tuple[T, ...]
722723
self.assertIs(typing._eval_type(TTE, globals(), locals()), Tuple[T, ...])
723724

src/test_typing.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,10 +743,11 @@ def test_extended_generic_rules_repr(self):
743743
self.assertEqual(repr(Callable[[], List[T]][int]).replace('typing.', ''),
744744
'Callable[[], List[int]]')
745745

746-
def test_generic_forvard_ref(self):
747-
def foobar(x: List[List['T']]): ...
746+
def test_generic_forward_ref(self):
747+
def foobar(x: List[List['CC']]): ...
748+
class CC: ...
749+
self.assertEqual(get_type_hints(foobar, globals(), locals()), {'x': List[List[CC]]})
748750
T = TypeVar('T')
749-
self.assertEqual(get_type_hints(foobar, globals(), locals()), {'x': List[List[T]]})
750751
def barfoo(x: Tuple[T, ...]): ...
751752
self.assertIs(get_type_hints(barfoo, globals(), locals())['x'], Tuple[T, ...])
752753

0 commit comments

Comments
 (0)