File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
custom_components/pyscript Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -545,9 +545,10 @@ async def resolve_nonlocals(self, ast_ctx):
545545 self .local_sym_table [var_name ] = sym_table [var_name ]
546546 break
547547 else :
548- val = await ast_ctx .ast_name (ast .Name (id = var_name , ctx = ast .Load ()))
549- if isinstance (val , EvalName ) and got_dot < 0 :
550- raise SyntaxError (f"no binding for nonlocal '{ var_name } ' found" )
548+ if var_name in nonlocal_names :
549+ val = await ast_ctx .ast_name (ast .Name (id = var_name , ctx = ast .Load ()))
550+ if isinstance (val , EvalName ) and got_dot < 0 :
551+ raise SyntaxError (f"no binding for nonlocal '{ var_name } ' found" )
551552
552553 def get_decorators (self ):
553554 """Return the function decorators."""
Original file line number Diff line number Diff line change @@ -338,6 +338,16 @@ def foo(arg=6):
338338 ],
339339 [
340340 """
341+ def func():
342+ global x
343+ x = 134
344+ func()
345+ x
346+ """ ,
347+ 134 ,
348+ ],
349+ [
350+ """
341351def foo0(arg=6):
342352 bar = 100
343353 bar2 = 1000
@@ -404,6 +414,19 @@ def foo1(arg=6):
404414 ],
405415 [
406416 """
417+ def f():
418+ def b():
419+ return s+g
420+ s = "hello "
421+ return b
422+ b = f()
423+ g = "world"
424+ b()
425+ """ ,
426+ "hello world" ,
427+ ],
428+ [
429+ """
407430@dec_test("abc")
408431def foo(cnt=4):
409432 sum = 0
You can’t perform that action at this time.
0 commit comments