File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -798,3 +798,34 @@ def test_each_thread_gets_separate_instance() -> None:
798798
799799 # Each thread should get a separate reused instance
800800 assert id1 != id2
801+
802+ [case testGeneratorWithUndefinedLocalInEnvironment]
803+ from typing import Iterator
804+
805+ from testutil import assertRaises
806+
807+ def gen(set: bool) -> Iterator[float]:
808+ if set:
809+ y = float("-113.0")
810+ yield 1.0
811+ yield y
812+
813+ def test_bitmap_is_cleared_when_object_is_reused() -> None:
814+ # This updates the bitmap of the shared instance.
815+ list(gen(True))
816+
817+ # Ensure bitmap has been cleared.
818+ with assertRaises(AttributeError): # TODO: Should be UnboundLocalError
819+ list(gen(False))
820+
821+ def gen2(set: bool) -> Iterator[int]:
822+ if set:
823+ y = int("5")
824+ yield 1
825+ yield y
826+
827+ def test_undefined_int_in_environment() -> None:
828+ list(gen2(True))
829+
830+ with assertRaises(AttributeError): # TODO: Should be UnboundLocalError
831+ list(gen2(False))
You can’t perform that action at this time.
0 commit comments