micropython.const inconsistent behaviour in class
Port, board and/or hardware
Waveshare ESP32-C3-Zero Development Board
MicroPython version
MicroPython v1.25.0 on 2025-04-15; ESP32C3 module with ESP32C3
Reproduction
with_const.py
from micropython import const
class HelloWorld:
TEST = const("Hello World!")
def __init__(self):
print(TEST)
>>> import with_const
>>> hello_world = with_const.HelloWorld()
Hello World!
>>>
without_const.py
class HelloWorld:
TEST = "Hello World!"
def __init__(self):
print(TEST)
>>> import without_const
>>> hello_world = without_const.HelloWorld()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "without_const.py", line 5, in __init__
NameError: name 'TEST' isn't defined
>>>
I wouldn't have noticed that I wasn't properly referencing my class constant variable if it wasn't for PyLint telling me I was making mistakes. This seems like a bug?
Expected behaviour
I expected the example using micropython.const() to error.
Observed behaviour
There is no error.
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
creating virtual timer on MicroPython v1.25.0 on esp32 s3 fails
Port, board and/or hardware
esp32 s3
MicroPython version
MicroPython v1.25.0 on 2025-04-15; Generic ESP32S3 module with ESP32S3
Reproduction
import machine
t = machine.Timer(-1)
Expected behaviour
no error on MicroPython v1.24.1 on 2024-11-29; Generic ESP32S3 module with ESP32S3
Observed behaviour
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid Timer number
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree