Commit graph

5853 commits

Author SHA1 Message Date
Scott Shawcroft
283aac23be
Fix subclassing dict
The get, set and del item methods didn't correctly lookup the value
from the parent native instance because the functions took the type
from the instance.

Fixes #8758
2024-01-23 15:39:57 -08:00
Scott Shawcroft
9538e0067b
Merge remote-tracking branch 'adafruit/main' into ww_sd_card 2024-01-22 17:14:06 -08:00
6b74263a71
uvc: Experimental module for USB video
This allows the CircuitPython device to act as a UVC video source.
2024-01-22 10:44:42 -06:00
Scott Shawcroft
61ec3280d1
Optimize error messages 2024-01-19 21:31:58 -08:00
Bill Sideris
af249bc86a
Revert "Please the beast?"
This reverts commit a7e45014a5.
2024-01-17 23:36:13 +02:00
Bill Sideris
b4c982f83f
Change micropython string 2024-01-17 23:32:28 +02:00
Bill Sideris
a7e45014a5
Please the beast? 2024-01-17 23:29:49 +02:00
Bill Sideris
f4a6acd136
Change sys.version to return the whole port identification 2024-01-17 22:40:31 +02:00
iabdalkader
215a982c14 py/py.mk: Remove extra build dir created for frozen_content.
This was originally needed because the .c --> .o rule is:

    $(BUILD)/%.o: %.c

and because the generated frozen_content.c is inside build-FOO, it must
therefore generate build-FOO/build-FOO/frozen_content.o.

But 2eda513870 added a new build rule for
pins.c that can also be used for frozen_content.c.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-01-17 08:14:15 +11:00
ec42e35ae7
enable bitmapfilter only on esp32s3 for now
we want it for memento, and maybe for qualia. we can add it elsewhere
later if we want
2024-01-11 14:42:55 -06:00
75be426377
Add "bitmapfilter"
bitmapfilter.morph is taken from openmv's imlib.

It is substantially faster than blur/sharpen implemented in ulab,
by up to 10x. It also avoids making many allocations.
2024-01-05 14:16:00 -06:00
Damien George
9b8c64c9ce all: Bump version to 1.22.1.
Signed-off-by: Damien George <damien@micropython.org>
2024-01-05 12:33:34 +11:00
1bc616cfb5
Merge pull request #8749 from jepler/mbedtls-hashlib
Share the implementation of hashlib across ports
2024-01-04 10:34:22 -06:00
Damien George
2037edb5a2 all: Bump version to 1.23.0-preview.
Signed-off-by: Damien George <damien@micropython.org>
2024-01-02 18:11:41 +11:00
Dan Halbert
035569d7fe recent MicroPython broke out binascii.crc32() 2023-12-29 11:32:04 -05:00
Damien George
9feb0689ee all: Bump version to 1.22.0.
Signed-off-by: Damien George <damien@micropython.org>
2023-12-27 15:35:31 +11:00
5d1b49516c
Enable io.IOBase so we can construct a RequestsStreamWrapper in Python code 2023-12-24 10:49:59 -06:00
5aa203f13e
Restore CIRCUITPY-CHANGEs for stream protocols
We mark all protocols with their type using MP_PROTO_IMPLEMENT,
and checking in mp_get_stream{,_raise}.

This was not turning up as a problem in tests until a (new, not yet
commited) change to jpegio caused a segfault because a type implementing
a different protocol was passed in to mp_get_stream.

By using 0 (instead of MP_QSTR_protocol_stream) as the marker for
objects implementing the standard micropython stream protocol, the
number of CIRCUITPY-CHANGEs is minimized.
2023-12-24 10:41:54 -06:00
51e3d5ecbf
Add a note about this makeqstrdata change 2023-12-24 10:41:54 -06:00
93dd2d5d46
Fix a typo that prevented setting CIRCUITPY_HASHLIB_MBEDTLS properly 2023-12-22 20:13:01 -06:00
3d61e63834
Don't bring in mbedtls if hashlib is off 2023-12-22 19:29:29 -06:00
080cc545b3
Share the implementation of hashlib across ports
.. many platforms can use mbedtls to implement hashlib.

Compile-tested with pico-w. Tested on feather rp2040 dvi.
2023-12-22 17:06:12 -06:00
Peter Züger
d69e69adb6 py/mkrules.mk: Fix dependency file generation for compiler wrappers.
When compiling with distcc, it does not understand the -MD flag on its own.
This fixes the interaction by explicitly adding the -MF option.

The error in distcc is described here under "Problems with gcc -MD":
https://www.distcc.org/faq.html

Signed-off-by: Peter Züger <zueger.peter@icloud.com>
2023-12-22 11:07:59 +11:00
Maarten van der Schrieck
3bca93b2d0 ports: Fix sys.stdout.buffer.write() return value.
MicroPython code may rely on the return value of sys.stdout.buffer.write()
to reflect the number of bytes actually written. While in most scenarios a
write() operation is successful, there are cases where it fails, leading to
data loss. This problem arises because, currently, write() merely returns
the number of bytes it was supposed to write, without indication of
failure.

One scenario where write() might fail, is where USB is used and the
receiving end doesn't read quickly enough to empty the receive buffer. In
that case, write() on the MicroPython side can timeout, resulting in the
loss of data without any indication, a behavior observed notably in
communication between a Pi Pico as a client and a Linux host using the ACM
driver.

A complex issue arises with mp_hal_stdout_tx_strn() when it involves
multiple outputs, such as USB, dupterm and hardware UART. The challenge is
in handling cases where writing to one output is successful, but another
fails, either fully or partially. This patch implements the following
solution:

mp_hal_stdout_tx_strn() attempts to write len bytes to all of the possible
destinations for that data, and returns the minimum successful write
length.

The implementation of this is complicated by several factors:
- multiple outputs may be enabled or disabled at compiled time
- multiple outputs may be enabled or disabled at runtime
- mp_os_dupterm_tx_strn() is one such output, optionally containing
  multiple additional outputs
- each of these outputs may or may not be able to report success
- each of these outputs may or may not be able to report partial writes

As a result, there's no single strategy that fits all ports, necessitating
unique logic for each instance of mp_hal_stdout_tx_strn().

Note that addressing sys.stdout.write() is more complex due to its data
modification process ("cooked" output), and it remains unchanged in this
patch. Developers who are concerned about accurate return values from
write operations should use sys.stdout.buffer.write().

This patch might disrupt some existing code, but it's also expected to
resolve issues, considering that the peculiar return value behavior of
sys.stdout.buffer.write() is not well-documented and likely not widely
known. Therefore, it's improbable that much existing code relies on the
previous behavior.

Signed-off-by: Maarten van der Schrieck <maarten@thingsconnected.nl>
2023-12-22 10:32:46 +11:00
Damien George
97b13132b1 py/gc: Improve calculation of new heap size in split-heap-auto mode.
There are two main changes here to improve the calculation of the size of
the next heap area when automatically expanding the heap:
- Compute the existing total size by counting the total number of GC
  blocks, and then using that to compute the corresponding number of bytes.
- Round the bytes value up to the nearest multiple of BYTES_PER_BLOCK.

This makes the calculation slightly simpler and more accurate, and makes
sure that, in the case of growing from one area to two areas, the number
of bytes allocated from the system for the second area is the same as the
first.  For example on esp32 with an initial area size of 65536 bytes, the
subsequent allocation is also 65536 bytes.  Previously it was a number that
was not even a multiple of 2.

Signed-off-by: Damien George <damien@micropython.org>
2023-12-19 18:34:23 +11:00
Trent Piepho
0e706a62b1 py/makeqstrdefs.py: Stop generating temporary intermediate file.
In "cat" mode, output was written to a file named "out", then moved to the
location of the real output file.  There was no reason for this.

While makeqstrdefs.py does make an effort to not update the timestamp on an
existing output file that has not changed, the intermediate "out" file
isn't part of the that process.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
2023-12-14 22:55:08 -08:00
Trent Piepho
f22e88611d py/makeqstrdefs.py: Don't skip output for stale hash file.
In "cat" mode a "$output_file.hash" file is checked to see if the hash of
the new output is the same as the existing, and if so the output file isn't
updated.

However, it's possible that the output file has been deleted but the hash
file has not.  In this case the output file is not created.

Change the logic so that a hash file is considered stale if there is no
output file and still create the output.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
2023-12-15 15:48:07 +11:00
Trent Piepho
0d93392f10 py/mkrules.mk: List hash files as byproducts.
These are produced by the "cat" command to makeqstrdefs.py, to allow it to
not update unchanged files.  cmake doesn't know about them and so they are
not removed on a "clean".

This triggered a bug in makeqstrdefs.py where it would not recreate a
deleted output file (which is removed by clean) if a stale hash file with a
valid hash still existed.

Listing them as byproducts will cause them to be deleted on clean.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
2023-12-15 15:48:07 +11:00
stijn
85c02166ca py/modsys: Implement optional sys.intern.
Signed-off-by: stijn <stijn@ignitron.net>
2023-12-15 11:43:39 +11:00
40722741dd
makeqstrdata: ensure certain qstrs are as early as possible
Some qstrs like those representing binary ops such as __add__ must have
qstr numbers that fit in 8 bits. Replace the former ad-hoc method,
which sorted *other* dunder-identifiers early with a list of all
the qstrs that have this requirement.

Before this, the unix coverage build was failing when I added certain
qstrs like "<input>" for a codeop filename default value.
2023-12-14 17:19:26 -06:00
9477574dfc
Add codeop.compile_command
This function in standard Python is a building block for custom REPLs:
```python
from codeop import compile_command

print("Repl in (Circuit-)Python")
ns = {}

PS1="<<< "
PS2=",,, "
command = ""
while True:
    line = input(PS2 if command else PS1)
    if command:
        command = command + "\n" + line
    else:
        command = line
    try:
        if (code := compile_command(command)):
            command = ""
            exec(code, ns)
    except Exception as e:
        command = ""
        print(e)
```
2023-12-14 09:23:23 -06:00
Scott Shawcroft
ca1b680d27
Merge pull request #8696 from jepler/jpegdecoder
Jpegdecoder
2023-12-08 15:35:29 -08:00
21de0a7349
Enable jpegio almost anywhere we can 2023-12-08 14:42:24 -06:00
Angus Gratton
f5be0128e4 py: Add port-agnostic inline functions for event handling.
These are intended to replace MICROPY_EVENT_POLL_HOOK and
MICROPY_EVENT_POLL_HOOK_FAST, which are insufficient for tickless ports.

This implementation is along the lines suggested here:
https://github.com/micropython/micropython/issues/12925#issuecomment-1803038430

Currently any usage of these functions expands to use the existing hook
macros, but this can be switched over port by port.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-12-08 12:47:00 +11:00
bd86b44848
Add JpegDecoder 2023-12-05 12:11:53 -06:00
1e37f57443
move RGBMATRIX block to be alphabetic 2023-12-05 10:42:41 -06:00
Bill Sideris
186fa35138
Enable compile on all ports. 2023-12-04 22:00:32 +02:00
Damien George
bfdf500ea5 py/mphal: Move configuration of ATOMIC_SECTION macros to mphal.h.
MICROPY_BEGIN_ATOMIC_SECTION/MICROPY_END_ATOMIC_SECTION belong more to the
MicroPython HAL rather than build configuration settings, so move their
default configuration to py/mphal.h, and require all users of these macros
to include py/mphal.h (here, py/objexcept.c and py/scheduler.c).

This helps ports separate configuration from their HAL implementations, and
can improve build times (because mpconfig.h is included everywhere, whereas
mphal.h is not).

Signed-off-by: Damien George <damien@micropython.org>
2023-12-01 14:14:08 +11:00
Dan Halbert
ad0949dcf5
Merge pull request #8663 from jepler/disable-fortify-source
Unset D_FORTIFY_SOURCE globally
2023-11-28 15:55:06 -05:00
b54330a1c6
Update py/circuitpy_defns.mk
Co-authored-by: Scott Shawcroft <scott@tannewt.org>
2023-11-28 14:54:04 -06:00
Dan Halbert
1cfb894c50
Merge pull request #8655 from jepler/save-flash-share-utf8
Save flash by sharing the 'to utf-8' implementation
2023-11-28 10:47:41 -05:00
a14eb26d4b
Unset D_FORTIFY_SOURCE globally 2023-11-28 08:21:02 -06:00
3c8f9f4dab
py/modbuiltins: Share vstr_add_char's implementation of utf8 encoding.
This saves ~84 bytes on trinket m0, and saves 112 bytes on PYBV10.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2023-11-28 07:56:03 -06:00
9c7067d9ad py/modbuiltins: Share vstr_add_char's implementation of utf8 encoding.
This saves ~84 bytes on trinket m0, and saves 112 bytes on PYBV10.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2023-11-28 23:34:56 +11:00
Jim Mussared
992cd64555 py/mkrules: Add support for custom manifest variables.
This allows e.g. a board (or make command line) to set

    MICROPY_MANIFEST_MY_VARIABLE = path/to/somewhere
    set(MICROPY_MANIFEST_MY_VARIABLE path/to/somewhere)

and then in the manifest.py they can query this, e.g. via

    include("$(MY_VARIABLE)/path/manifest.py")

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-28 23:28:15 +11:00
Dan Halbert
567c273e46 ESP32-S3 BLE: set up Characteristic properly during discovery 2023-11-21 20:53:05 -05:00
Damien George
f397a3ec31 py/objslice: Validate that the argument to indices() is an integer.
Otherwise passing in a non-integer can lead to an invalid memory access.

Thanks to Junwha Hong and Wonil Jang @S2Lab, UNIST for finding the issue.

Fixes issue #13007.

Signed-off-by: Damien George <damien@micropython.org>
2023-11-21 22:28:57 +11:00
3a68d2f621
Fix build error when frozen modules are updated
When a frozen module was added or updated, a build error would occur
during CI: `KeyError: 'FROZEN_MPY_DIRS'`.

In e40abda1bc I decided that it should be an error if all the expected
keys were not defined in the board settings dict. I made this change
and all seemed to be well; however, my testing did not exercise the
case that a frozen module was changed.

It turns out that FROZEN_MPY_DIRS was not being set in the board settings
dict because the output of print-FROZEN_MPY_DIRS was "FROZEN_MPY_DIRS ="
(which does not match the regular expression) instead of
"FROZEN_MPY_DIRS = " (with a trailing space).

This change fixes the problem by ensuring that an undefined or empty
variable still prints with a space character after the equal character.

Tested by running locally:
```
python3 -c 'import shared_bindings_matrix; print(shared_bindings_matrix.get_settings_from_makefile("ports/atmel-samd", "trinket_m0")["FROZEN_MPY_DIRS"])'
```
(prints a blank line, expected)

as well as simulating a change to the asyncio frozen submodule:
```
python3 -c 'import shared_bindings_matrix; print(shared_bindings_matrix.get_settings_from_makefile("ports/atmel-samd", "trinket_m0")["FROZEN_MPY_DIRS"])'
```
(which will build the elecfreaks_picoed board)
2023-11-18 09:43:36 -06:00
stijn
a968888f69 py/obj: Fix mp_obj_is_type compilation with C++.
Fixes issue #12951.

Signed-off-by: stijn <stijn@ignitron.net>
2023-11-17 14:31:42 +11:00
Dan Halbert
58b111d428
Merge pull request #8608 from jepler/add-locale-module
Add `locale.getlocale()`
2023-11-15 09:24:04 -05:00
46bfbad1bb
Add locale.getlocale()
This returns the localization of the running CircuitPython, such as
en_US, fr, etc.

Additional changes are needed in build infrastructure since the
string "en_US" should not appear to be translated in weblate, ever;
instead the value comes from the translation metadata.

Closes: #8602
2023-11-14 21:20:03 -06:00
Scott Shawcroft
8ff0682937
Merge pull request #8605 from tannewt/fix_esp_heap_alloc
Fix split heap on ESP
2023-11-14 14:52:28 -08:00
Scott Shawcroft
1f2355742b
Fix split heap on ESP
It was setting the DMA capability requirement which excludes PSRAM.

Fixes #8597. Fixes #8573.
2023-11-14 12:00:59 -08:00
Scott Shawcroft
4bdd3e6150
Merge pull request #8589 from jepler/issue8588
Rework ci_fetch_deps and use it from makefiles too
2023-11-14 10:04:37 -08:00
fb840159fb
Remove some stuff about reserved psram & supervisor allocations
this is obsoleted by the new split heap code 🎉
2023-11-13 12:55:26 -06:00
6db9f2e73f
Rework ci_fetch_deps and use it from makefiles too
* teach ci_fetch_deps about --filter=blob:none
 * change logic ensuring tags in frozen/ are fetched
 * since check=True was all the time, remove unused kwarg
 * add fetch-board-submodules

Closes: #8588
2023-11-12 12:32:34 -06:00
Andrew Leech
4cf741062b extmod/vfs_reader: Add file ioctl to set read buffer size.
Can be used to speed up importing a file from a vfs based filesystem.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2023-11-09 11:20:31 +11:00
Dan Halbert
191a5a31c7
add CIRCUITPY-CHANGE annotations 2023-11-08 09:08:10 -05:00
stijn
958c6d917d windows: Use the MicroPython logo as application icon.
Add a .ico file with common icon image size, created from
vector-logo-2.png, and embed it into the resulting executable.

Signed-off-by: stijn <stijn@ignitron.net>
2023-11-07 17:22:52 +11:00
Jim Mussared
4212799fd8 py/qstr: Special case qstr_find_strn for empty string.
This handles the case where an empty bytes/bytearray/str could pass in
NULL as the str argument (with length zero). This would result in UB in
strncmp. Even though our bare-metal implementation of strncmp handles
this, best to avoid it for when we're using system strncmp.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-07 16:01:50 +11:00
Jim Mussared
b6a9778484 py/misc: Change sizeof to offsetof for variable-length alloc.
This fixes the case where e.g.

    struct foo_t {
      mp_obj_t x;
      uint16_t y;
      char buf[];
    };

will have `sizeof(struct foo_t)==8`, but `offsetof(struct foo_t, buf)==6`.

When computing the size to allocate for `m_new_obj_var` we need to use
offsetof to avoid over-allocating. This is important especially when it
might cause it to spill over into another GC block.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03 16:03:18 +11:00
Mathieu Serandour
c85db05244 py/lexer: Change token position for new lines.
Set the position of new line tokens as the end of the preceding line
instead of the beginning of the next line.  This is done by first moving
the pointer to the end of the current line to skip any whitespace, record
the position for the token, then finaly skip any other line and whitespace.

The previous behavior was to skip every new line and whitespace, including
the indent of the next line, before recording the token position.

(Note that both lex->emit_dent and lex->nested_bracket_level equal 0 if
had_physical_newline == true, which allows simplifying the if-logic for
MP_TOKEN_NEWLINE.)

And update the cmd_parsetree.py test expected output, because the position
of the new-line token has changed.

Fixes issue #12792.

Signed-off-by: Mathieu Serandour <mathieu.serandour@numworks.fr>
2023-11-03 15:56:10 +11:00
Damien George
9a4d4db3a1 py/runtime: Remove declaration of function from inside function.
Signed-off-by: Damien George <damien@micropython.org>
2023-11-03 15:21:51 +11:00
Jim Mussared
2eda513870 py/mkrules.mk: Add rule for compiling auto-generated source files.
This prevents each port Makefile from having to add an explicit rule for
`build-BOARD/pins_BOARD.c`.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03 13:57:47 +11:00
Scott Shawcroft
8137e2d6d2
Switch all ports to auto-growing split heap
This simplifies allocating outside of the VM because the VM doesn't
take up all remaining memory by default.

On ESP we delegate to the IDF for allocations. For all other ports,
we use TLSF to manage an outer "port" heap. The IDF uses TLSF
internally and we use their fork for the other ports.

This also removes the dynamic C stack sizing. It wasn't often used
and is not possible with a fixed outer heap.

Fixes #8512. Fixes #7334.
2023-11-01 15:24:16 -07:00
Alessandro Gatti
95ce61d0ad esp32: Use better build settings for ESP32-C3.
ESP32-C3 is not Xtensa-based, so build settings are now tailored a bit
better following that fact.  ESP-IDF 5.x already adds architecture-specific
modules by itself so there is no need to specify either the `xtensa` or the
`riscv` module in the build settings.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2023-11-01 11:38:09 +11:00
2296c85e29
fix another error seen only on clean builds 2023-10-30 16:25:25 +01:00
774f6ac6ab
Switch to using MP_ERROR_TEXT instead of translate, globally 2023-10-30 09:49:06 +01:00
Jim Mussared
64c79a5423 py/qstr: Add support for sorted qstr pools.
This provides a significant performance boost for qstr_find_strn, which is
called a lot during parsing and loading of .mpy files, as well as interning
of string objects (which happens in most string methods that return new
strings).

Also adds comments to explain the "static" qstrs.  These are part of the
.mpy ABI and avoid needing to duplicate string data for QSTRs known to
already be in the firmware.  The static pool isn't currently sorted, but in
the future we could either split the static pool into the sorted regions,
or in the next .mpy version just sort them.

Based on initial work done by @amirgon in #6896.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-30 11:10:02 +11:00
Dan Halbert
32b6ac79d5
Merge pull request #8519 from jepler/compressed-message-type
Rename compressed_string_t to mp_rom_error_text_t to match upstream
2023-10-27 10:53:44 -04:00
Alessandro Gatti
b6c369a396 py/asm{arm,thumb,x64,x86,xtensa}: Remove unused macros.
`ASM_MOV_REG_IMM_FIX_U16` and `ASM_MOV_REG_IMM_FIX_WORD` are no longer
used anywhere in the code.

See discussion in #12771.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2023-10-27 15:41:02 +11:00
Jim Mussared
3bf70f16e9 py/mkrules.mk: Add MICROPY_PREVIEW_VERSION_2.
This provides a way to enable features and changes slated for MicroPython
2.x, by running `make MICROPY_PREVIEW_VERSION_2=1`. Also supported for
the cmake ports (except Zephyr).

This is an alternative to having a 2.x development branch (or equivalently,
keeping a 1.x release branch). Any feature or change that needs to be
"hidden" until 2.x can use this flag (either in the Makefile or the
preprocessor).

A good example is changing function arguments or other public API features,
in particular to aid in improving consistency between ports.

When `MICROPY_PREVIEW_VERSION_2` is enabled, the REPL banner is amended to
say "MicroPython (with v2.0 preview) vX.Y.Z", and sys.implementation gets a
new field `_v2` set to `True`.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-27 15:28:46 +11:00
Scott Shawcroft
cf08ef0b80
Enable warnings in full builds only 2023-10-26 13:43:04 -07:00
Dan Halbert
3f1b9af025 py/mpprint.c: fix formatting 2023-10-26 15:30:42 -04:00
c695f8b20f
remove some unneeded diffs 2023-10-26 19:39:43 +02:00
a069dc92e0
restore cprintf/vcprintf prototypes 2023-10-26 19:39:26 +02:00
Scott Shawcroft
f439f02492
Add warnings and warn about displayio changes
Follow up to #8493
2023-10-25 15:45:45 -07:00
de541cf155
Fix pointer-ness, const-ness of compressed messages
micropython puts the pointer-ness into the typedef; we can put the
const-ness there too.

this reduces the delta to micropython; for instance, emitinlinextensa
and emitinlinethumb now match upstream.
2023-10-25 21:40:11 +02:00
54a5878ee0
WIP 2023-10-25 21:24:52 +02:00
Scott Shawcroft
be30c12a74
Pass subobject into native subscr
This allows PixelBuf to call transmit after setting a value.

Fixes #8488
2023-10-25 11:44:32 -07:00
acf350a1b7
In py/ use MP_ERROR_TEXT instead of translate 2023-10-25 08:19:31 +02:00
55874b6470
Rename compressed_string_t to mp_rom_error_text_t to match upstream 2023-10-25 08:14:13 +02:00
Scott Shawcroft
63079c75b0
Re-add passing native methods the subclass instance
Fixes #8488
2023-10-24 16:20:51 -07:00
Scott Shawcroft
e62db5adcd
Fix native property setting from subclass 2023-10-24 16:20:51 -07:00
Scott Shawcroft
e1df598199
Split displayio hardware support from core
These are moved:
* Display -> busdisplay.BusDisplay
* FourWire -> fourwire.FourWire
* EPaperDisplay -> epaperdisplay.EPaperDisplay
* I2CDisplay -> i2cdisplaybus.I2CDisplayBus

`paralleldisplay` is now `paralleldisplaybus` (and registered as
`paralleldisplay` too).

Bus related helpers are split out of display_core into bus_core.
It is in still displayio since it is a dependency of both
busdisplay and epaperdisplay.

Fixes #7667
2023-10-24 15:43:34 -07:00
Scott Shawcroft
168c40e940
Merge pull request #8508 from dhalbert/v1.21-merge
V1.21 merge
2023-10-24 15:36:06 -07:00
Scott Shawcroft
ecaf9e6b14
Fix native emitter compile 2023-10-24 14:48:02 -07:00
Scott Shawcroft
d8148559c2
Enable native subpackage support 2023-10-24 13:49:18 -07:00
Scott Shawcroft
d14bb575cb
Fix mp_frozen_names 2023-10-24 13:02:09 -07:00
Dan Halbert
2c795acf1e py/compile.c: add missing line for native labels in await 2023-10-24 15:39:26 -04:00
Bob Abeles
6725be4259 And formatting, again 2023-10-23 20:43:57 -07:00
Bob Abeles
3f4332be80 Another CI formatting issue 2023-10-23 20:40:51 -07:00
Bob Abeles
892d89e8b7 Fix CI detected line-length issue 2023-10-23 20:35:31 -07:00
Bob Abeles
2e996587fe Improve make translation data performance. 2023-10-23 20:08:15 -07:00
Dan Halbert
6cd5150ac1 fix gc_free() to build in mpy-cross 2023-10-23 20:44:03 -04:00
Dan Halbert
3f0b807e74 pre-commit C formatting fix 2023-10-23 20:37:42 -04:00
Dan Halbert
8f254035dd pre-commit fixes 2023-10-23 20:14:40 -04:00
Scott Shawcroft
f13ea9a49f
Fix async tests by adding back __await__ use. Remove u* lookup 2023-10-23 16:13:11 -07:00
Damien George
bb4be837c3 py/makeqstrdefs.py: Print a nicer error when preprocessing stage fails.
Signed-off-by: Damien George <damien@micropython.org>
2023-10-23 10:39:39 +11:00
Dan Halbert
8017a1ad30 ports/unix VARIANT=coverage fixes 2023-10-20 16:51:04 -04:00
7ab5252cdd
Add CIRCUITPY_MESSAGE_COMPRESSION_LEVEL
to trade compile speed & flash size

Initially enable the faster mode on rp2040 and espressif, where there's
usually plenty of flash available (these advanced techniques save hundreds
to thousands of bytes, which is important on a lot of old samd21 boards
but is a drop in the lake of a 4MB flash chip)
2023-10-20 19:18:18 +01:00
Dan Halbert
fdfc4421b1 MICROPY_NONSTANDARD_TYPECODES default; check MICROPY_PY_ERRNO in objexcept.c 2023-10-20 13:35:38 -04:00
Dan Halbert
6eb0607a53 fix build when MICROPY_PY_ERRNO is 0 2023-10-20 10:43:22 -04:00
Dan Halbert
4b42a6f4a0 restore old uzlib; remove remaining U and u prefixes 2023-10-19 21:29:57 -04:00
Dan Halbert
367e13c69f change CIRCUITPY change markers to CIRCUITPY-CHANGE 2023-10-19 16:42:36 -04:00
Dan Halbert
c0a4abc03c Fix merge bugs; remove shared/tinyusb/* 2023-10-19 16:02:42 -04:00
Dan Halbert
f2ebe6839c Initial MicroPython v1.21.0 merge; not compiled yet 2023-10-18 17:49:14 -04:00
Jim Mussared
3883f29485 py/modthread: Initialise nlr_jump_callback_top on threads.
The main thread gets this because the thread state is in bss, but
subsequent threads need this field to be initialised.

Also added a note to mpstate.h to help avoid missing this in the future.

Fixes issue #12695.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-18 09:18:23 +11:00
Damien George
6967ff3c58 py/persistentcode: Bump .mpy sub-version.
This is required because the previous commit changed the .mpy native ABI.

Signed-off-by: Damien George <damien@micropython.org>
2023-10-16 11:25:31 +11:00
Damien George
9b63421fb3 py/dynruntime: Add mp_get_buffer.
Signed-off-by: Damien George <damien@micropython.org>
2023-10-16 11:23:11 +11:00
Damien George
9c7ea9b14a py/obj: Generalise mp_get_buffer so it can raise if a flag is set.
This allows mp_get_buffer_raise() to be changed to a simple inline function
that in the majority of cases costs the same (in code size) to call as the
original mp_get_buffer_raise(), because the flags argument is a constant.

Signed-off-by: Damien George <damien@micropython.org>
2023-10-16 11:22:55 +11:00
Damien George
516385c4cc py/objboundmeth: Optimise check for types in binary_op.
Signed-off-by: Damien George <damien@micropython.org>
2023-10-13 15:29:09 +11:00
Daniël van de Giessen
4f5e165d0b py/objboundmeth: Support comparing and hashing bound methods.
This behaviour matches CPython.  It's useful to be able to store bound
method objects in dicts/sets, and compare for equality, eg when storing
them in a list and using list.remove().

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2023-10-13 15:11:49 +11:00
Dan Halbert
2f391e5679 restore SUPEROPT_GC, SUPEROPT_VM 2023-10-12 15:25:28 -04:00
Dan Halbert
a13185bb34 fix inclusion of ulab sources 2023-10-12 11:03:00 -04:00
Jim Mussared
5015779a6f py/builtinevex: Handle invalid filenames for execfile.
If a non-string buffer was passed to execfile, then it would be passed
as a non-null-terminated char* to mp_lexer_new_from_file.

This changes mp_lexer_new_from_file to take a qstr instead (as in almost
all cases a qstr will be created from this input anyway to set the
`__file__` attribute on the module).

This now makes execfile require a string (not generic buffer) argument,
which is probably a good fix to make anyway.

Fixes issue #12522.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-12 15:17:59 +11:00
Scott Shawcroft
9633c4e78f
Merge remote-tracking branch 'adafruit/main' into v1.20-merge 2023-10-11 11:21:57 -07:00
Scott Shawcroft
6e278900bd
Only include mpconfigport.h once 2023-10-11 10:04:03 -07:00
Scott Shawcroft
9be3999e78
Add back makefile print variable 2023-10-11 10:04:02 -07:00
Scott Shawcroft
2910dea6fd
Almost fix extra_coverage test 2023-10-11 10:04:02 -07:00
Scott Shawcroft
22a44c6003
Try and fix mpy-cross variants 2023-10-11 10:03:46 -07:00
Dan Halbert
7869706551 force FROZEN_MANIFEST build; add back make print-% 2023-10-10 22:10:17 -04:00
Matthias Urlichs
3fb1bb131f py/vm: Don't emit warning when using "raise ... from None".
"Raise SomeException() from None" is a common Python idiom to suppress
chained exceptions and thus shouldn't trigger a warning on a version of
Python that doesn't support them in the first place.
2023-10-09 09:46:02 +11:00
Jim Mussared
69e34b6b6b all: Switch to new preview build versioning scheme.
See https://github.com/micropython/micropython/issues/12127 for details.

Previously at the point when a release is made, we update mpconfig.h
and set a git tag. i.e. the version increments at the release.

Now the version increments immediately after the release. The workflow is:
1. Final commit in the cycle updates mpconfig.h to set (X, Y, 0, 0) (i.e.
   clear the pre-release state).
2. This commit is tagged "vX.Y.0".
3. First commit for the new cycle updates mpconfig.h to set (X, Y+1, 0, 1)
   (i.e. increment the minor version, set the pre-release state).
4. This commit is tagged "vX.Y+1.0-preview".

The idea is that a nightly build is actually a "preview" of the _next_
release. i.e. any documentation describing the current release may not
actually match the nightly build. So we use "preview" as our semver
pre-release identifier.

Changes in this commit:
 - Add MICROPY_VERSION_PRERELEASE to mpconfig.h to allow indicating that
   this is not a release version.
 - Remove unused MICROPY_VERSION integer.
 - Append "-preview" to MICROPY_VERSION_STRING when the pre-release state
   is set.
 - Update py/makeversionhdr.py to no longer generate MICROPY_GIT_HASH.
 - Remove the one place MICROPY_GIT_HASH was used (it can use
   MICROPY_GIT_TAG instead).
 - Update py/makeversionhdr.py to also understand
   MICROPY_VERSION_PRERELEASE in mpconfig.h.
 - Update py/makeversionhdr.py to convert the git-describe output into
   semver-compatible "X.Y.Z-preview.N.gHASH".
 - Update autobuild.sh to generate filenames using the new scheme.
 - Update remove_old_firmware.py to match new scheme.
 - Update mpremote's pyproject.toml to handle the "-preview" suffix in the
   tag. setuptools_scm maps to this "rc0" to match PEP440.
 - Fix docs heading where it incorrectly said "vvX.Y.Z" for release docs.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-06 12:10:14 +11:00
Damien George
e00a144008 all: Bump version to 1.21.0.
Signed-off-by: Damien George <damien@micropython.org>
2023-10-06 10:32:07 +11:00
Scott Shawcroft
bf3d84195f
Fix decompressing using qstrs after running the VM
The qstr state still pointed to qstr pools in the released MP heap.
2023-10-05 14:56:11 -07:00
Scott Shawcroft
49511b0746
Bring back ordereddict.move_to_end() 2023-10-05 12:48:45 -07:00
Scott Shawcroft
94c7082e9c
Fix super init. CP changed it to support kwargs 2023-10-05 12:44:30 -07:00
Scott Shawcroft
18c03a74dd
Fix a few tests
* Re-enable a couple FATFS configurations we added.
* Remove MICROPY_PY_IO_FILEIO.
* Remove uasyncio from standard unix build.
* Re-add our unicode printing improvements.
2023-10-05 10:59:08 -07:00
Dan Halbert
7e0e6fcdca Metro M4 now compiles 2023-10-03 15:03:59 -04:00
Damien George
cf490a7091 all: Fix various spelling mistakes found by codespell 2.2.6.
Signed-off-by: Damien George <damien@micropython.org>
2023-10-03 11:24:50 +11:00
1b9ecabf8b
Fix constructing empty namedtuple
this change from micropython was not taken with the merge
2023-10-02 09:08:03 -05:00
18a5a897f1
makeqstrdef: restore CIRCUITPY behavior
this fixes the qrio test, among others
2023-10-02 08:50:47 -05:00
1ccce65311
file no longer used 2023-10-02 08:48:19 -05:00
6d59e55599
fix making mpy-cross automatically 2023-10-02 07:28:19 -05:00
Dan Halbert
2fc5a934a1 add back generic subscript iterator, gc_never_free 2023-09-29 23:01:02 -04:00
Dan Halbert
68a2927385 MP_REGISTER_ROOT_POINTER for port-specific root pointers 2023-09-29 15:46:42 -04:00
Dan Halbert
1c388ab315 finish converting to MP_REGISTER_ROOT_POINTER() 2023-09-29 10:49:34 -04:00
Jim Mussared
276bfa3146 py/lexer: Add missing initialisation for fstring_args_idx.
This was missed in 692d36d779. Probably
never noticed because everything enables `MICROPY_GC_CONSERVATIVE_CLEAR`,
but found via ASAN thanks to @gwangmu & @chibinz.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-09-29 13:58:26 +10:00
Ihor Nehrutsa
d83c1a43d4 py: Change ifdef DEBUG_PRINT to if DEBUG_PRINT.
Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
2023-09-29 13:04:38 +10:00
Angus Gratton
2fcd28f713 py/mkrules.mk: Don't strip binary if STRIP variable is unset.
This provides a way to build a non-DEBUG host binary that still has symbols
and debug information.

Document this for the unix port, and update a comment in the unix port
Makefile.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-09-29 13:01:12 +10:00
Dan Halbert
76ff01452b Trinket M0 comes up; still very much wip 2023-09-28 16:22:10 -04:00
MicroDev
27fd60d739
implement suggested changes
- update the docs
- split out common `watchdog_reset`
- revert to using `None` instead of `WatchDogMode.NONE`
2023-09-24 15:23:38 +00:00
cd462c51b3
re-fix stream function definition 2023-09-22 14:26:36 -05:00
2c3d81148e
re-add CP-specific C files 2023-09-22 14:26:25 -05:00
c53cb3ef25
re-add CP-specific exception related types 2023-09-22 14:26:13 -05:00
79309c1208
re-add CP-specific exception types 2023-09-22 14:25:50 -05:00
4bbf42c4c3
fix duplicate array_locals_dict_table 2023-09-22 14:25:36 -05:00
7c2fbff965
fix use of locals_dict 2023-09-22 14:25:23 -05:00
99479a69f8
fix definition of slice type with optional "make_new" 2023-09-22 13:56:36 -05:00
e48984872b
allow definition of namedtuples in core 2023-09-22 13:56:16 -05:00
a181172336
remove redundant declaratoin 2023-09-22 13:55:24 -05:00
0265ae07f8
remove unused functions 2023-09-22 13:55:15 -05:00
51314fb7de
fix availability of mp_obj_array_locals_dict 2023-09-22 13:55:08 -05:00
2c70537aba
fix memoryview cast&hex 2023-09-22 13:54:20 -05:00
085cf0e3e4
make mp_stream_flush available 2023-09-22 13:52:04 -05:00
556ec9d300
fixes for mp_type_get_protocol_slot 2023-09-22 13:51:57 -05:00
566688b028
fix mpy magic numbers 2023-09-22 13:50:35 -05:00
bb0f8149df
fix circuitpy memoryview.cast 2023-09-22 13:44:48 -05:00
0d796249e8
remove unused function 2023-09-22 13:43:47 -05:00
5367c9f7ef
fix "native exception getter" 2023-09-22 13:42:19 -05:00
f9f75d8202
MAKE_ENUM_TYPE for new style type defs 2023-09-22 13:39:24 -05:00
Scott Shawcroft
7bad82a219
C6 compiles, runs but wifi crashes 2023-09-22 10:02:35 -07:00
6b5c7b6ce6
fix const vs static generatorexit again 2023-09-22 10:45:49 -05:00
9dda69cf9e
add missing declarations that got lost in the merge 2023-09-22 10:40:11 -05:00
f77e0b8992
fix comment marker 2023-09-22 10:39:50 -05:00
60fa26022b
build fixes for persistent code 2023-09-22 10:39:41 -05:00
5c0f8f7786
fixes for circuitpython nativeglue 2023-09-22 10:39:28 -05:00
a285a33076
Restore our defines for exception chaining 2023-09-22 10:39:12 -05:00
9104654930
makeqstrdata: ensure _lt and _gt qstrs are sorted early
this fixes a build error because their numbers have to be <256
2023-09-22 10:38:52 -05:00
Dan Halbert
10b95a1998 add translate.h and linker.h includes back to runtime.h; remove linker.h refs; remove top-level lib/cyw43-driver 2023-09-20 22:00:09 -04:00
a00f2d8940
array extend/append need extern linkage & right names 2023-09-20 11:46:51 -05:00
7a386545ca
re-add translation make rules 2023-09-20 11:46:35 -05:00
a760794449
re-add objtraceback.o 2023-09-20 11:46:22 -05:00
f83a235c85
re-add mp_obj_exception_get_native 2023-09-20 11:46:14 -05:00
76ef77a620
fix exception chaining, preprocessor error 2023-09-20 11:26:57 -05:00
e068ff7234
fix compile errors, fix mp_raise prototypes 2023-09-20 11:26:41 -05:00
1ab884ab0f
fix compile errors 2023-09-20 11:26:26 -05:00
c87703512a
fix conditional nesting 2023-09-20 11:26:17 -05:00
37c8b0df9c
fix argument name 2023-09-20 11:26:03 -05:00
6b8ee2ca6f
remove old python style checking for "special accessors"
this appears to be properly handled by other (new?) code, but
tests will tell.
2023-09-20 11:25:58 -05:00
bb6d530c1d
slots & macro moved to header 2023-09-20 11:25:09 -05:00
7806044e5e
string construction changed 2023-09-20 11:25:01 -05:00
9cedfc4cbd
implemented as macro now 2023-09-20 11:24:53 -05:00
ee51968d9d
can't be static, is called from builtins 2023-09-20 11:24:45 -05:00
4ed939f26e
fix compile error 2023-09-20 11:24:26 -05:00
680b94d463
fix compile erors 2023-09-20 11:24:22 -05:00
be62395c47
fix indentation 2023-09-20 11:24:15 -05:00
f9fb567a07
fix CP vs MP differences in exception-throwing functions 2023-09-20 11:24:07 -05:00
37a881f4d3
Get the type object for the constructor call 2023-09-20 11:23:49 -05:00
082b299a0c
spelling 2023-09-20 11:23:39 -05:00
8e00c69cdf
spelling 2023-09-20 11:22:34 -05:00
cd3ca6b6a6
fix array object name 2023-09-20 11:22:25 -05:00
fb2eb6a7d9
add mp_obj_is_tuple_compatible 2023-09-20 11:22:01 -05:00
e4e58ac223
add mp_obj_get_type_qstr 2023-09-20 11:21:56 -05:00
a9d6661d5b
add and fix exception prototypes 2023-09-20 11:21:50 -05:00
b499b7fdc2
add missing type objects 2023-09-20 11:21:34 -05:00
57c3dfd579
fix missing define of NONSTANDARD_TYPECODES 2023-09-20 11:21:10 -05:00
649ea62f57
fix typo 2023-09-20 11:21:02 -05:00
73612ac119
Fix availability of MP_ERROR_TEXT in misc.h 2023-09-20 11:20:56 -05:00