Fix unbound local variable after exception inside with statement (PY-13919)

Change control flow to make it more correct for with statement. Handle special case for Unbound local variable inspection and add tests
This commit is contained in:
Elizaveta Shashkova
2017-11-29 20:25:09 +03:00
parent 0728950d07
commit 1ac30ed12d
7 changed files with 76 additions and 3 deletions

View File

@@ -0,0 +1,7 @@
with context_manager:
if c:
raise ValueError
val = c
print(val)

View File

@@ -0,0 +1,15 @@
0(1) element: null
1(2) element: PyWithStatement
2(3) READ ACCESS: context_manager
3(4) element: PyIfStatement
4(5,9) READ ACCESS: c
5(6) element: PyStatementList. Condition: c:true
6(7) ASSERTTYPE ACCESS: c
7(8) element: PyRaiseStatement
8(12,14) READ ACCESS: ValueError
9(10) element: PyAssignmentStatement
10(11) READ ACCESS: c
11(12) WRITE ACCESS: val
12(13) element: PyPrintStatement
13(14) READ ACCESS: val
14() element: null