Skip to content

Commit 4ad5e29

Browse files
committed
Test undefined attribute
1 parent 2b0e4e8 commit 4ad5e29

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

mypyc/test-data/run-generators.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff 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))

0 commit comments

Comments
 (0)