Commit graph

17285 commits

Author SHA1 Message Date
d53177561e uctypes: Fix kw-constructing structures
before this, the following would go wrong:
```
>>> r1 = mactypes.Rect(top=671, left=52, bottom=149, right=529)
>>> print(r1.top, r1.left, r1.bottom, r1.right)
52 671 0 0
```
because the progress along the kwargs was mis-counted
2025-07-19 20:08:13 -05:00
a6531ef7f1 mkapi: Add field name to typeerrors 2025-07-18 15:27:29 -05:00
6632d33688 update README 2025-07-18 15:26:23 -05:00
46fd408d0d docs: start adding some m68kmac specific docs
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-18 15:26:11 -05:00
600ff44226 uctypes: Show "can't assign to aggregate" as an error.
.. instead of the non-specific "syntax error".
2025-07-18 11:02:43 -05:00
d1e704b37a uctypes: Support copying & updating of the whole struct object.
The following operations on uctypes structs are now supported:

```
lhs[:] = buffer # Replace the whole content of lhs with buffer
copy = rhs[:]   # Make an identical copy of rhs in a fresh buffer
```

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-18 11:02:43 -05:00
ed20d74052 docs: remove unneeded stuff 2025-07-18 11:02:43 -05:00
0f5a9e8148
Merge pull request #11 from m68k-micropython/struct-types 2025-07-18 03:26:24 +01:00
1d3bf9f19b m68kmac: Wrap many core parts of the OS.
This is enough to create a window & draw to it! 🎉

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-17 20:55:38 -05:00
7ff5b6cf59 objarray: Allow creating uninitialized bytearray.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-17 20:51:01 -05:00
13fbd43610 moductypes: Add types.
This is an experiment. I want the usual Python guarantee that
you can't just footgun yourself by passing the wrong thing through
a pointer argument, at least as much as is practical.

But a uctypes struct doesn't have a type of its own, like Point
or Rect; you can only check that the *size* matches some
underlying expected size.

This change allows a type like Rect to be defined in the core,
and of course if it's a distinct Python type it can be checked
in the core as well.

Restore the unix tests so we can test the added core functionality.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-17 20:51:01 -05:00
a80f00bac2 export tx_strn
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-17 20:45:47 -05:00
61a679fdd4 README: these turned into Issues.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-17 20:45:46 -05:00
132e94128a pre-commit: let ruff auto-fix.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-17 20:45:46 -05:00
c50a2dde87 modtime: Speculative fix
The RTC time needs to be converted
to the micropython epoch time.
2025-07-07 19:11:00 +01:00
c98fe8262e mkapi: fix DrawText 2025-07-07 19:10:45 +01:00
0f08dfa1b6 console: Save pen state too
.. and lump portSetter with fontSetup,
it's a mistake to use the latter
without the former.
2025-07-07 19:10:20 +01:00
7dacf1bd8c update submodule 2025-07-07 19:09:44 +01:00
f6340c8208 Use our own fork of multiverse. 2025-07-07 19:07:34 +01:00
228d8789d5 update bug report template 2025-07-07 10:40:30 +01:00
ff8682c2c7 Improve arrow key handling
This is verified to still work on infinite mac
as well as in a modified umac.
2025-07-07 09:27:58 +01:00
64346ff800 Quiet down mkapi output 2025-07-07 09:25:11 +01:00
0eed348799 Adopt date-based versioning 2025-07-06 20:24:13 +01:00
f9bf7af637 Update issue templates and other github meta 2025-07-06 20:23:42 +01:00
7e94850e71 Doc improvements, build improvements 2025-07-06 17:15:20 +01:00
7a75037b39 m68kmac: Add a port to m68k Macintosh.
This is lightly tested with umac emulating a 4MB Macintosh Plus.
2025-07-06 16:42:28 +01:00
a17107275f ci: Enable format checking in many builds.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 08:55:03 +01:00
4629294ca7 nrf: Can't list format plugin on linker commandline.
.. so filter it out, similar to stm32.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 08:55:03 +01:00
8c42a164ca stm32: Don't list format plugin on linker commandline.
It causes an error, so filter it out, similar to other compile-only
flags.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 08:24:57 +01:00
0a77b72df8 mpprint: Rework integer vararg handling.
This adds support for %llx (needed by XINT_FMT for printing cell
objects) and incidentally support for capitalized output of %P.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 08:24:06 +01:00
753dd076ca micropython_checks: Add compiler plugin.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 08:24:06 +01:00
16d34d4700 coverage: Avoid type checking an invalid string.
we still want this not to crash a runtime but the
new static checker wouldn't like it.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 08:24:06 +01:00
42f127a799 netutils: Cast the ticks value before printing.
Before, the compiler plugin produced an error in the PYBD_SF6
build, which is a nanboxing build with 64-bit ints.

I made the decision here to cast the value even though some
significant bits might be lost after 49.7 days. However, the
format used is "% 8d", which produces a consistent width
output for small ticks values (up to about 1.1 days). I judged
that it was more valuable to preserve the fixed width display
than to accurately represent long time periods.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 08:24:06 +01:00
b8b61636a9 stm32: Add casts when printing small integers.
All these arguments are of type `mp_{u,}int_t`, but the actual
value is always a small integer. Cast it so that it can format
with the %d/%u formatter.

Before, the compiler plugin produced an error in the PYBD_SF6
build, which is a nanboxing build with 64-bit ints.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 08:24:03 +01:00
275e048b29 modlwip: Print timeout with correct format string.
As timeout is of type `mp_int_t`, it must be printed with INT_FMT.

Before, the compiler plugin produced an error in the PYBD_SF6
build, which is a nanboxing build with 64-bit ints.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 08:21:19 +01:00
f34089b312 objcell: Fix printing cell ID.
On the nanbox build, `o->obj` is a 64-bit type but `%p` formats
a 32-bit type, leading to undefined behavior.

Print the cell's ID as an integer instead.

It can't be printed in hex because the '%llx' format specifier is not
supported in mp_printf.

This location was found using an experimental gcc plugin for mp_printf
error checking.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-05 16:34:37 +01:00
dc3cb7eb91 coverage: Cast values to int for printing.
During the coverage test, all the values encountered are within the
range of %d.

These locations were found using an experimental gcc plugin
for mp_printf error checking.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-05 16:34:37 +01:00
c441585fda examplemodule: Cast arguments to printf.
These locations were found using an experimental gcc plugin
for mp_printf error checking.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-05 16:34:37 +01:00
10b3f93a42 core: Fix mp_printf integer size mismatches.
The type of the argument must match the format string. Add
casts to ensure that they do.

It's possible that casting from `size_t` to `unsigned` loses
the correct values by masking off upper bits, but it seems likely
that the quantities involved in practice are small enough that
the %u formatter (32 bits on most platforms, 16 on pic16bit) will
in fact hold the correct value.

The alternative, casting to a wider type, adds code size.

These locations were found using an experimental gcc plugin
for mp_printf error checking, cross-building for x64 windows
on Linux.

In one case there was already a cast, but it was written
incorrectly and did not have the intended effect.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-05 16:34:37 +01:00
15065adf56 coverage: Provide argmuents of expected types.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-05 16:34:37 +01:00
c675651902 coverage: Cast type names to qstr explicitly.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-05 16:34:37 +01:00
061eaefefb core: Cast type names to qstr explicitly.
The name field of type objects is of type uint16_t for efficiency,
but when the type is passed to mp_printf it must be cast explicitly
to type qstr.

These locations were found using an experimental gcc plugin
for mp_printf error checking, cross-building for x64 windows
on Linux.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-05 16:34:37 +01:00
Daniël van de Giessen
431b79146e esp32/panichandler: Support building against IDFv5.4.2.
The IDF panic handler resets the watchdog timeout to prevent the printing
of the error message from being cut off by a WDT reset.  We use the exact
same function call in our wrapper function for the same purpose.

In IDFv5.4.2 the function used for this was changed from
`esp_panic_handler_reconfigure_wdts` to `esp_panic_handler_feed_wdts`,
specifically in this commit:
cd887ef59a

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-07-06 00:14:10 +10:00
a9801f9960 github/workflows: Use Python 3.11 for unix coverage testing.
This removes the need for an explicit `sys_settrace_features.py.exp` file.

This means that people testing locally will also need to install Python
3.11 in some way, such as with pyenv or uv, and use it during
`make VARIANT=coverage test`, or they will get failures.

When using Python from GitHub actions/setup-python, pip3 can't be wrapped
by sudo, because this invokes the operating system python instead.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 00:08:54 +10:00
a8c2b917e2 tools/ci.sh: Increase test timeout to 60s in coverage jobs.
The additional overhead of the settrace profiler means that the
`aes_stress.py` test was running too slowly on GitHub CI.  Double the
timeout to 60 seconds.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 00:08:13 +10:00
e415d03e7f github/workflows: Remove the unix "settrace" CI job.
This becomes redundant when the main coverage build includes settrace.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 00:07:14 +10:00
db0a836fc1 py/profile: Fix printing lineno in frame objects.
The argument corresponding to a `%q` specifier must be of type `qstr`, not
a narrower type like `int16_t`.  Not ensuring this caused an assertion
error on one Windows x64 build.

The argument corresponding to a `%d` specifier must be of type `int`, not a
potentially-wider type like `mp_uint_t`.  Not ensuring this prevented the
function name from being printed on the unix nanbox build.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 00:06:34 +10:00
f33f1aa9d3 unix/coverage: Initialize more code_state fields.
When `MICROPY_PY_SYS_SETTRACE` was enabled, a crash was seen in the
qemu_mips build.  It seems likely that this was due to these added fields
not being initialized.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 00:06:14 +10:00
f04475afd8 py/runtime: Initialize profile fields in mp_thread_init_state.
If the fields added for `MICROPY_PY_SYS_SETTRACE` are not initialized
properly, their value in a thread is indeterminate.  In particular, if the
callback is not NULL, it will be invoked as a function.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 00:05:47 +10:00
ff8c4e5943 tests/misc: Improve test coverage of py/profile.c.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-06 00:05:36 +10:00