← index #281Issue #4272
Off-topic · high · value 2.305
QUERY · ISSUE

deepcopy function references a non-existant variable

openby dhylandsopened 2018-05-23updated 2019-02-21

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.

2 comments
harryofskyrim · 2019-02-21

SO? The issue is still present, and it's really unpleasant

dhylands · 2019-02-21

I just reported this on pfalcon's repository which is the "official" source of this repository.
https://github.com/pfalcon/micropython-lib/issues/26

CANDIDATE · ISSUE

Micropython allows access to 'nonlocal' variables without 'nonlocal' keyword

closedby ddiminnieopened 2018-10-25updated 2018-10-27

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).

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied