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):
545
545
self .local_sym_table [var_name ] = sym_table [var_name ]
546
546
break
547
547
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" )
551
552
552
553
def get_decorators (self ):
553
554
"""Return the function decorators."""
Original file line number Diff line number Diff line change @@ -338,6 +338,16 @@ def foo(arg=6):
338
338
],
339
339
[
340
340
"""
341
+ def func():
342
+ global x
343
+ x = 134
344
+ func()
345
+ x
346
+ """ ,
347
+ 134 ,
348
+ ],
349
+ [
350
+ """
341
351
def foo0(arg=6):
342
352
bar = 100
343
353
bar2 = 1000
@@ -404,6 +414,19 @@ def foo1(arg=6):
404
414
],
405
415
[
406
416
"""
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
+ """
407
430
@dec_test("abc")
408
431
def foo(cnt=4):
409
432
sum = 0
You can’t perform that action at this time.
0 commit comments