possible bug with viper code in class
Posted: Thu Jul 07, 2022 9:54 am
Good morning,
I seem to have found a possible bug in:
MicroPython v1.19.1 on 2022-06-18; Raspberry Pi Pico with RP2040
I reduced the code to just a few lines which show what happens.
Apparently the ›self.foobar‹ variable gets deleted but only when it's set to 0 in foo.bar()
Setting any other value works just fine.
Using the native decorator or no decorator at all works flawlessly.
Maybe someone can take a look and (if necessary) open a bug report (or point me to the correct place)
Thanks a lot.
I seem to have found a possible bug in:
MicroPython v1.19.1 on 2022-06-18; Raspberry Pi Pico with RP2040
I reduced the code to just a few lines which show what happens.
Code: Select all
#!/usr/bin/env python3
import micropython
class Foo:
@micropython.viper
def __init__(self):
self.foobar = 0
return
@micropython.viper
def bar(self):
self.foobar = 0 # looks like this line removes self.foobar from this instance
return
foo = Foo()
foo.bar() # works the first time
foo.bar() # now throws exception: AttributeError: 'Foo' object has no attribute 'foobar'
Setting any other value works just fine.
Using the native decorator or no decorator at all works flawlessly.
Maybe someone can take a look and (if necessary) open a bug report (or point me to the correct place)
Thanks a lot.