deepcopy function references a non-existant variable
In copy.py: https://github.com/micropython/micropython-lib/blob/f20d89c6aad9443a696561ca2a01f7ef0c8fb302/copy/copy.py#L163 the deepcopy function references the variable dispatch_table, which isn't initialized.
Micropython allows access to 'nonlocal' variables without 'nonlocal' keyword
It's not clear to me whether the behavior described below is a bug or a design decision (possibly for efficiency). It is a divergence from CPython behavior. (My apologies if this has been discussed elsewhere - a few quick searches did not turn up anything for me.)
Consider the following (sloppy) code:
def outer():
x = 1
def inner():
x += 1
print(x)
inner()
On CPython calling this function triggers an 'UnboundLocalError':
>>> outer()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in outer
File "<stdin>", line 4, in inner
UnboundLocalError: local variable 'x' referenced before assignment
In MicroPython/CircuitPython calling this function prints a value:
>>> outer()
2
Micropython does not have an UnboundLocalError exception... so perhaps a NameError could be raised instead?...
... or the 'MicroPython differences from CPython' documentation could be updated to add this difference (if it is, in fact, a design decision for efficiency).
SO? The issue is still present, and it's really unpleasant
I just reported this on pfalcon's repository which is the "official" source of this repository.
https://github.com/pfalcon/micropython-lib/issues/26