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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>