Skip to content

Commit b7cc563

Browse files
dlechlaurensvalk
authored andcommitted
bricks/stm32: Add umath alias for math module.
To be compatible with the `pybricks-api` we shouldn't have any modules with the same name as the Python standard library. Most MicroPython modules already have the "u" prefix, but `math` doesn't for some reason.
1 parent 4d6d172 commit b7cc563

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
This makes resetting the angle optional, allowing to maintain absolute
1111
positioning for robots with gears ([support#389]).
1212

13+
### Changed
14+
- Moved MicroPython `math` module to `umath` to be consistent with other
15+
MicroPython modules.
16+
1317
### Fixed
1418
- Fixed City hub not always powering off on shutdown ([support#385]).
1519

bricks/stm32/configport.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,17 @@ extern const struct _mp_obj_module_t pb_package_pybricks;
121121
#define _PYBRICKS_PACKAGE_PYBRICKS \
122122
{ MP_OBJ_NEW_QSTR(MP_QSTR_pybricks), (mp_obj_t)&pb_package_pybricks },
123123

124+
// HACK: math is one of the few MicroPython modules that doesn't start with "u"
125+
// so we add an alias for it until it is fixed upstream
126+
#if MICROPY_PY_MATH
127+
#define _UMATH_MODULE \
128+
{ MP_ROM_QSTR(MP_QSTR_umath), MP_ROM_PTR(&mp_module_math) },
129+
#else
130+
#define _UMATH_MODULE
131+
#endif
132+
124133
#define MICROPY_PORT_BUILTIN_MODULES \
134+
_UMATH_MODULE \
125135
_PYBRICKS_PACKAGE_PYBRICKS \
126136

127137

0 commit comments

Comments
 (0)