This repository was archived by the owner on Sep 16, 2024. It is now read-only.
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
utime: ticks_diff() raises an exception with large values returned by ticks_us() or ticks_ms() #113
Closed
Description
The functions utime.ticks_us() and utime.ticks_ms() may return values, which then cannot be used as input for utime.ticks_diff(). Example:
>>> time.ticks_us()
3636776263
>>> time.ticks_diff(time.ticks_us(), time.ticks_us()+1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: overflow converting long int to machine word
>>>
The reason is, that the return values are not stripped to values which can be representef by a MP_SMALL_INT, or at least 31 bit.
Edit: Funny enough, the utime module is mostly implemented twice, in esp32/mods/modutime.c and in py/extmod/mphal_utime.c, where the latter seems to have proper value/overflow handling.
Metadata
Metadata
Assignees
Labels
No labels