(self)
| 360 | iprc(cell) |
| 361 | |
| 362 | def test_nonlocal(self): |
| 363 | # fails if outer scope is not a function scope or if var not defined |
| 364 | with self.assertRaises(SyntaxError): |
| 365 | iprc("nonlocal x") |
| 366 | iprc( |
| 367 | """ |
| 368 | x = 1 |
| 369 | def f(): |
| 370 | nonlocal x |
| 371 | x = 10000 |
| 372 | yield x |
| 373 | """ |
| 374 | ) |
| 375 | iprc( |
| 376 | """ |
| 377 | def f(): |
| 378 | def g(): |
| 379 | nonlocal x |
| 380 | x = 10000 |
| 381 | yield x |
| 382 | """ |
| 383 | ) |
| 384 | |
| 385 | # works if outer scope is a function scope and var exists |
| 386 | iprc( |
| 387 | """ |
| 388 | def f(): |
| 389 | x = 20 |
| 390 | def g(): |
| 391 | nonlocal x |
| 392 | x = 10000 |
| 393 | yield x |
| 394 | """ |
| 395 | ) |
| 396 | |
| 397 | def test_execute(self): |
| 398 | iprc( |