Skip to content

Commit e5e9c5c

Browse files
authored
Merge pull request adafruit#9469 from dhalbert/merge-from-micropython-v1.22.2
Merge from micropython v1.22.2
2 parents dfc3e99 + 450cb49 commit e5e9c5c

File tree

392 files changed

+4992
-4674
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

392 files changed

+4992
-4674
lines changed

.codespell/exclude-file.txt

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ USB_PRODUCT = "BLOK"
55
print(binascii.b2a_base64(b"fo"))
66
# again, neither will "there" or "wither", since they have "the"
77
i1Qb$TE"rl
8+
ZEN = "the zen of python beautiful is better than ugly explicit is better than implicit simple is better than complex complex is better than complicated flat is better than nested sparse is better than dense readability counts special cases arent special enough to break the rules although practicality beats purity errors should never pass silently unless explicitly silenced in the face of ambiguity refuse the temptation to guess there should be one and preferably only one obvious way to do it although that way may not be obvious at first unless youre dutch now is better than never although never is often better than right now if the implementation is hard to explain its a bad idea if the implementation is easy to explain it may be a good idea namespaces are one honking great idea lets do more of those"
9+
"arent",
10+
"youre",

.git-blame-ignore-revs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# all: Update Python formatting to ruff-format.
2+
bbd8760bd9a2302e5abee29db279102bb11d7732
3+
14
# all: Fix various spelling mistakes found by codespell 2.2.6.
25
cf490a70917a1b2d38ba9b58e763e0837d0f7ca7
36

.gitattributes

+4-8
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
*.props text eol=crlf
1111
*.bat text eol=crlf
1212

13+
# CIRCUITPY-CHANGE: add some more binary types.
1314
# These are binary so should never be modified by git.
1415
*.a binary
16+
*.ico binary
1517
*.png binary
1618
*.jpg binary
1719
*.dxf binary
1820
*.mpy binary
21+
*.der binary
1922
*.deb binary
2023
*.zip binary
2124
*.pdf binary
@@ -24,11 +27,4 @@
2427
# These should also not be modified by git.
2528
tests/basics/string_cr_conversion.py -text
2629
tests/basics/string_crlf_conversion.py -text
27-
ports/stm32/pybcdc.inf_template -text
28-
ports/stm32/usbhost/** -text
29-
ports/cc3200/hal/aes.c -text
30-
ports/cc3200/hal/aes.h -text
31-
ports/cc3200/hal/des.c -text
32-
ports/cc3200/hal/i2s.c -text
33-
ports/cc3200/hal/i2s.h -text
34-
ports/cc3200/version.h -text
30+
# CIRCUITPY-CHANGE: remove non-CircuitPython tests

.github/workflows/run-tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ on:
99

1010
jobs:
1111
run:
12-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-24.04
1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
test: [all, mpy, native, native_mpy]
1717
env:
1818
CP_VERSION: ${{ inputs.cp-version }}
19-
MICROPY_CPYTHON3: python3.8
19+
MICROPY_CPYTHON3: python3.12
2020
MICROPY_MICROPYTHON: ../ports/unix/build-coverage/micropython
2121
TEST_all:
2222
TEST_mpy: --via-mpy -d basics float micropython
@@ -32,7 +32,7 @@ jobs:
3232
- name: Set up python
3333
uses: actions/setup-python@v5
3434
with:
35-
python-version: 3.8
35+
python-version: 3.12
3636
- name: Set up submodules
3737
uses: ./.github/actions/deps/submodules
3838
with:

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5+
# CIRCUITPY-CHANGES: many additions
6+
57
# Compiled Sources
68
###################
79
*.o

.pre-commit-config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# SPDX-License-Identifier: Unlicense
44

5+
# CIRCUITPY-CHANGE: CircuitPython-specific.
6+
57
repos:
68
- repo: https://github.com/pre-commit/pre-commit-hooks
79
rev: v4.0.1

LICENSE

+12-2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,15 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
22+
23+
--------------------------------------------------------------------------------
24+
25+
#CIRCUITPY-CHANGE:
26+
27+
Unless specified otherwise (see below), the above license and copyright applies
28+
to all files derived from MicroPython in this repository.
29+
30+
Individual files may include additional copyright holders and specify other licenses.
31+
See the comments and SPDX headers.

Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ check-stubs: stubs
282282
@(cd $(STUBDIR) && set -- */__init__.pyi && mypy "$${@%/*}")
283283
@tools/test-stubs.sh
284284

285+
.PHONY: update-frozen-libraries
285286
update-frozen-libraries:
286287
@echo "Updating all frozen libraries to latest tagged version."
287288
cd frozen; for library in *; do cd $$library; ../../tools/git-checkout-latest-tag.sh; cd ..; done
@@ -350,3 +351,16 @@ remove-all-submodules:
350351
.PHONY: fetch-tags
351352
fetch-tags:
352353
git fetch --tags --recurse-submodules=no --shallow-since="2023-02-01" https://github.com/adafruit/circuitpython HEAD
354+
355+
.PHONY: coverage
356+
coverage:
357+
make -j -C ports/unix VARIANT=coverage
358+
359+
.PHONY: coverage-clean
360+
coverage-fresh:
361+
make -C ports/unix VARIANT=coverage clean
362+
make -j -C ports/unix VARIANT=coverage
363+
364+
.PHONY: run-tests
365+
run-tests:
366+
cd tests; MICROPY_MICROPYTHON=../ports/unix/build-coverage/micropython ./run-tests.py

docs/library/sys.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Constants
6666
.. data:: maxsize
6767

6868
Maximum value which a native integer type can hold on the current platform,
69-
or maximum value representable by CircuitPython integer type, if it's smaller
69+
or maximum value representable by the CircuitPython integer type, if it's smaller
7070
than platform max value (that is the case for CircuitPython ports without
7171
long int support).
7272

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import os
22

33
# Directory that the project lives in, aka ../..
4-
SITE_ROOT = '/'.join(os.path.dirname(__file__).split('/')[0:-2])
4+
SITE_ROOT = "/".join(os.path.dirname(__file__).split("/")[0:-2])
55

66
TEMPLATE_DIRS = (
7-
"%s/templates/" % SITE_ROOT, # Your custom template directory, before the RTD one to override it.
8-
"%s/readthedocs/templates/" % SITE_ROOT, # Default RTD template dir
7+
"%s/templates/"
8+
% SITE_ROOT, # Your custom template directory, before the RTD one to override it.
9+
"%s/readthedocs/templates/" % SITE_ROOT, # Default RTD template dir
910
)

examples/usercmodule/cppexample/example.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
extern "C" {
22
#include <examplemodule.h>
3+
#include <py/objstr.h>
34

45
// Here we implement the function using C++ code, but since it's
56
// declaration has to be compatible with C everything goes in extern "C" scope.
67
mp_obj_t cppfunc(mp_obj_t a_obj, mp_obj_t b_obj) {
8+
// The following no-ops are just here to verify the static assertions used in
9+
// the public API all compile with C++.
10+
MP_STATIC_ASSERT_STR_ARRAY_COMPATIBLE;
11+
if (mp_obj_is_type(a_obj, &mp_type_BaseException)) {
12+
}
13+
714
// Prove we have (at least) C++11 features.
815
const auto a = mp_obj_get_int(a_obj);
916
const auto b = mp_obj_get_int(b_obj);

extmod/extmod.mk

+95
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# and provides rules to build 3rd-party components for extmod modules.
33

44
# CIRCUITPY-CHANGE: many extmod modules removed
5+
# CIRCUITPY-CHANGE: modzlib.c still used
56
SRC_EXTMOD_C += \
67
extmod/modasyncio.c \
78
extmod/modbinascii.c \
@@ -37,6 +38,96 @@ SRC_QSTR += $(SRC_EXTMOD_C)
3738
CFLAGS += $(CFLAGS_EXTMOD) $(CFLAGS_THIRDPARTY)
3839
LDFLAGS += $(LDFLAGS_EXTMOD) $(LDFLAGS_THIRDPARTY)
3940

41+
################################################################################
42+
# libm/libm_dbl math library
43+
44+
# Single-precision math library.
45+
SRC_LIB_LIBM_C += $(addprefix lib/libm/,\
46+
acoshf.c \
47+
asinfacosf.c \
48+
asinhf.c \
49+
atan2f.c \
50+
atanf.c \
51+
atanhf.c \
52+
ef_rem_pio2.c \
53+
erf_lgamma.c \
54+
fmodf.c \
55+
kf_cos.c \
56+
kf_rem_pio2.c \
57+
kf_sin.c \
58+
kf_tan.c \
59+
log1pf.c \
60+
math.c \
61+
nearbyintf.c \
62+
roundf.c \
63+
sf_cos.c \
64+
sf_erf.c \
65+
sf_frexp.c \
66+
sf_ldexp.c \
67+
sf_modf.c \
68+
sf_sin.c \
69+
sf_tan.c \
70+
wf_lgamma.c \
71+
wf_tgamma.c \
72+
)
73+
74+
# Choose only one of these sqrt implementations, software or hardware.
75+
SRC_LIB_LIBM_SQRT_SW_C += lib/libm/ef_sqrt.c
76+
SRC_LIB_LIBM_SQRT_HW_C += lib/libm/thumb_vfp_sqrtf.c
77+
78+
# Double-precision math library.
79+
SRC_LIB_LIBM_DBL_C += $(addprefix lib/libm_dbl/,\
80+
__cos.c \
81+
__expo2.c \
82+
__fpclassify.c \
83+
__rem_pio2.c \
84+
__rem_pio2_large.c \
85+
__signbit.c \
86+
__sin.c \
87+
__tan.c \
88+
acos.c \
89+
acosh.c \
90+
asin.c \
91+
asinh.c \
92+
atan.c \
93+
atan2.c \
94+
atanh.c \
95+
ceil.c \
96+
cos.c \
97+
cosh.c \
98+
copysign.c \
99+
erf.c \
100+
exp.c \
101+
expm1.c \
102+
floor.c \
103+
fmod.c \
104+
frexp.c \
105+
ldexp.c \
106+
lgamma.c \
107+
log.c \
108+
log10.c \
109+
log1p.c \
110+
modf.c \
111+
nearbyint.c \
112+
pow.c \
113+
rint.c \
114+
round.c \
115+
scalbn.c \
116+
sin.c \
117+
sinh.c \
118+
tan.c \
119+
tanh.c \
120+
tgamma.c \
121+
trunc.c \
122+
)
123+
124+
# Choose only one of these sqrt implementations, software or hardware.
125+
SRC_LIB_LIBM_DBL_SQRT_SW_C += lib/libm_dbl/sqrt.c
126+
SRC_LIB_LIBM_DBL_SQRT_HW_C += lib/libm_dbl/thumb_vfp_sqrt.c
127+
128+
# Too many warnings in libm_dbl, disable for now.
129+
$(BUILD)/lib/libm_dbl/%.o: CFLAGS += -Wno-double-promotion -Wno-float-conversion
130+
40131
################################################################################
41132
# VFS FAT FS
42133

@@ -75,6 +166,7 @@ SRC_THIRDPARTY_C += $(addprefix $(LITTLEFS_DIR)/,\
75166
lfs2_util.c \
76167
)
77168

169+
# CIRCUITPY-CHANGE: -Wno-missing-field-initializers instead of -Wno-shadow
78170
$(BUILD)/$(LITTLEFS_DIR)/lfs2.o: CFLAGS += -Wno-missing-field-initializers
79171
endif
80172

@@ -235,6 +327,9 @@ SRC_THIRDPARTY_C += $(addprefix $(LWIP_DIR)/,\
235327
core/ipv6/nd6.c \
236328
netif/ethernet.c \
237329
)
330+
ifeq ($(MICROPY_PY_LWIP_LOOPBACK),1)
331+
CFLAGS_EXTMOD += -DLWIP_NETIF_LOOPBACK=1
332+
endif
238333
ifeq ($(MICROPY_PY_LWIP_SLIP),1)
239334
CFLAGS_EXTMOD += -DMICROPY_PY_LWIP_SLIP=1
240335
SRC_THIRDPARTY_C += $(LWIP_DIR)/netif/slipif.c

extmod/lwip-include/lwipopts.h

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef uint32_t sys_prot_t;
2323
#define LWIP_NETCONN 0
2424
#define LWIP_SOCKET 0
2525

26+
// CIRCUITPY-CHANGE: #if instead of #ifdef
2627
#if MICROPY_PY_LWIP_SLIP
2728
#define LWIP_HAVE_SLIPIF 1
2829
#endif

extmod/misc.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ bool mp_os_dupterm_is_builtin_stream(mp_const_obj_t stream);
3939
void mp_os_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached);
4040
uintptr_t mp_os_dupterm_poll(uintptr_t poll_flags);
4141
int mp_os_dupterm_rx_chr(void);
42-
void mp_os_dupterm_tx_strn(const char *str, size_t len);
42+
int mp_os_dupterm_tx_strn(const char *str, size_t len);
4343
void mp_os_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc);
4444
#else
45-
#define mp_os_dupterm_tx_strn(s, l)
45+
static inline int mp_os_dupterm_tx_strn(const char *s, size_t l) {
46+
return -1;
47+
}
4648
#endif
4749

4850
#endif // MICROPY_INCLUDED_EXTMOD_MISC_H

extmod/modasyncio.c

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#if MICROPY_PY_ASYNCIO
3333

34+
// CIRCUITPY-CHANGE
3435
#if CIRCUITPY && !(defined(__unix__) || defined(__APPLE__))
3536
#include "shared-bindings/supervisor/__init__.h"
3637
#endif
@@ -308,6 +309,7 @@ STATIC mp_obj_t task_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
308309
STATIC mp_obj_t task_iternext(mp_obj_t self_in) {
309310
mp_obj_task_t *self = MP_OBJ_TO_PTR(self_in);
310311
if (TASK_IS_DONE(self)) {
312+
// CIRCUITPY-CHANGE
311313
if (self->data == mp_const_none) {
312314
// Task finished but has already been sent to the loop's exception handler.
313315
mp_raise_StopIteration(MP_OBJ_NULL);

extmod/modbinascii.c

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#if MICROPY_PY_BINASCII
3636

37+
// CIRCUITPY-CHANGE: added
3738
static void check_not_unicode(const mp_obj_t arg) {
3839
#if MICROPY_CPYTHON_COMPAT
3940
if (mp_obj_is_str(arg)) {

extmod/modhashlib.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ STATIC mp_obj_t hashlib_sha256_digest(mp_obj_t self_in) {
114114

115115
#else
116116

117+
// CIRCUITPY-CHANGE
117118
static void check_not_unicode(const mp_obj_t arg) {
118119
#if MICROPY_CPYTHON_COMPAT
119120
if (mp_obj_is_str(arg)) {
@@ -136,6 +137,7 @@ STATIC mp_obj_t hashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args
136137
}
137138

138139
STATIC mp_obj_t hashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) {
140+
// CIRCUITPY-CHANGE
139141
check_not_unicode(arg);
140142
mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in);
141143
hashlib_ensure_not_final(self);
@@ -306,7 +308,7 @@ STATIC mp_obj_t hashlib_md5_digest(mp_obj_t self_in) {
306308

307309
#if MICROPY_SSL_MBEDTLS
308310

309-
#if MBEDTLS_VERSION_NUMBER < 0x02070000
311+
#if MBEDTLS_VERSION_NUMBER < 0x02070000 || MBEDTLS_VERSION_NUMBER >= 0x03000000
310312
#define mbedtls_md5_starts_ret mbedtls_md5_starts
311313
#define mbedtls_md5_update_ret mbedtls_md5_update
312314
#define mbedtls_md5_finish_ret mbedtls_md5_finish

0 commit comments

Comments
 (0)