You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MicroPython 1.25.0 introduced a breaking change, aligning the behaviour
of the int() function with the behaviour of CPython (assume a decimal
number, unless a base is specified. Only if a base of 0 is specified
will the base be inferred from the string).
This commit implements a new custom parsing function `parse_int`. It
can correctly parse the following string literals:
* 0x[0-9]+ -> treated as hex
* 0b[0-9]+ -> treated as binary
* 0o[0-9]+ -> treated as octal (Python style)
* 0[0-9]+ -> treated as octal (GNU as style)
* anything else parsed as decimal
It only handles the GNU as style octal case directly, letting the
original `int()` function handle the other cases (using base 0).
In fact, the GNU as octal case was not handled correctly previously,
and this commit fixes that.
Some new tests for previous functionality were added to show that
both new and previous cases are being handled correctly.
Note: GNU as does not actually accept the octal prefix 0o..., but we
accept it as a convenience, as this is accepted in Python code. This
means however, that our assembler accepts code which GNU as does not
accept. But the other way around, we still accept all code that GNU
as accepts, which was one of our goals.
0 commit comments