Skip to content

Commit 15cc202

Browse files
authored
Merge pull request #10417 from dhalbert/micropython-v1.24.1-merge
Micropython v1.24.1 merge
2 parents a634a47 + ce450dc commit 15cc202

File tree

294 files changed

+5807
-4378
lines changed

Some content is hidden

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

294 files changed

+5807
-4378
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ bin/
3939
circuitpython-stubs/
4040
test-stubs/
4141
build-*/
42+
docs/genrst/
4243

43-
# Test failure outputs
44+
# Test failure outputs and intermediate artifacts
4445
######################
4546
tests/results/*
47+
tests/ports/unix/ffi_lib.so
4648

4749
# Python cache files
4850
######################
@@ -76,6 +78,7 @@ TAGS
7678
####################
7779
*~
7880

81+
# MacOS desktop metadata files
7982
*.DS_Store
8083
**/*.DS_Store
8184
*.icloud
@@ -100,6 +103,7 @@ TAGS
100103
.cache
101104

102105
**/CLAUDE.local.md
106+
.claude
103107

104108
# windsurf rules
105109
.windsurfrules

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
url = https://github.com/micropython/axtls.git
88
[submodule "lib/libffi"]
99
path = lib/libffi
10-
url = https://github.com/atgreen/libffi
10+
url = https://github.com/libffi/libffi
1111
[submodule "lib/berkeley-db-1.xx"]
1212
path = lib/berkeley-db-1.xx
1313
url = https://github.com/micropython/berkeley-db-1.xx

LICENSE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2023 Damien P. George
3+
Copyright (c) 2013-2024 Damien P. George
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -22,8 +22,6 @@ THE SOFTWARE.
2222

2323
--------------------------------------------------------------------------------
2424

25-
# CIRCUITPY-CHANGE:
26-
2725
Unless specified otherwise (see below), the above license and copyright applies
2826
to all files derived from MicroPython in this repository.
2927

docs/library/builtins.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,9 @@ Functions and types
8686

8787
.. class:: int()
8888

89-
.. classmethod:: from_bytes(bytes, byteorder)
89+
.. classmethod:: from_bytes(bytes, byteorder="big", *, signed=False)
9090

91-
In CircuitPython, the ``byteorder`` parameter must be positional (this is
92-
compatible with CPython).
93-
94-
.. method:: to_bytes(size, byteorder)
95-
96-
In CircuitPython, the ``byteorder`` parameter must be positional (this is
97-
compatible with CPython).
91+
.. method:: to_bytes(length=1, byteorder="big", *, signed=False)
9892

9993
.. function:: isinstance()
10094

docs/library/micropython.rst

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
:mod:`micropython` -- MicroPython extensions and internals
2-
==========================================================
1+
:mod:`micropython` -- access and control MicroPython internals
2+
==============================================================
33

44
.. module:: micropython
55
:synopsis: access and control MicroPython internals
@@ -26,3 +26,132 @@ Functions
2626
provided as part of the :mod:`micropython` module mainly so that scripts can be
2727
written which run under both CPython and MicroPython, by following the above
2828
pattern.
29+
30+
.. CIRCUITPY-CHANGE: REMOVE .. function:: opt_level([level])
31+
32+
If *level* is given then this function sets the optimisation level for subsequent
33+
compilation of scripts, and returns ``None``. Otherwise it returns the current
34+
optimisation level.
35+
36+
The optimisation level controls the following compilation features:
37+
38+
- Assertions: at level 0 assertion statements are enabled and compiled into the
39+
bytecode; at levels 1 and higher assertions are not compiled.
40+
- Built-in ``__debug__`` variable: at level 0 this variable expands to ``True``;
41+
at levels 1 and higher it expands to ``False``.
42+
- Source-code line numbers: at levels 0, 1 and 2 source-code line number are
43+
stored along with the bytecode so that exceptions can report the line number
44+
they occurred at; at levels 3 and higher line numbers are not stored.
45+
46+
The default optimisation level is usually level 0.
47+
48+
.. CIRCUITPY-CHANGE: REMOVE .. function:: alloc_emergency_exception_buf(size)
49+
50+
Allocate *size* bytes of RAM for the emergency exception buffer (a good
51+
size is around 100 bytes). The buffer is used to create exceptions in cases
52+
when normal RAM allocation would fail (eg within an interrupt handler) and
53+
therefore give useful traceback information in these situations.
54+
55+
A good way to use this function is to put it at the start of your main script
56+
(eg ``boot.py`` or ``main.py``) and then the emergency exception buffer will be active
57+
for all the code following it.
58+
59+
.. CIRCUITPY-CHANGE: REMOVE .. function:: mem_info([verbose])
60+
61+
Print information about currently used memory. If the *verbose* argument
62+
is given then extra information is printed.
63+
64+
The information that is printed is implementation dependent, but currently
65+
includes the amount of stack and heap used. In verbose mode it prints out
66+
the entire heap indicating which blocks are used and which are free.
67+
68+
.. CIRCUITPY-CHANGE: REMOVE .. function:: qstr_info([verbose])
69+
70+
Print information about currently interned strings. If the *verbose*
71+
argument is given then extra information is printed.
72+
73+
The information that is printed is implementation dependent, but currently
74+
includes the number of interned strings and the amount of RAM they use. In
75+
verbose mode it prints out the names of all RAM-interned strings.
76+
77+
.. CIRCUITPY-CHANGE: REMOVE .. function:: stack_use()
78+
79+
Return an integer representing the current amount of stack that is being
80+
used. The absolute value of this is not particularly useful, rather it
81+
should be used to compute differences in stack usage at different points.
82+
83+
.. CIRCUITPY-CHANGE: REMOVE .. function:: heap_lock()
84+
.. CIRCUITPY-CHANGE: REMOVE .. function:: heap_unlock()
85+
.. CIRCUITPY-CHANGE: REMOVE .. function:: heap_locked()
86+
87+
Lock or unlock the heap. When locked no memory allocation can occur and a
88+
`builtins.MemoryError` will be raised if any heap allocation is attempted.
89+
`heap_locked()` returns a true value if the heap is currently locked.
90+
91+
These functions can be nested, ie `heap_lock()` can be called multiple times
92+
in a row and the lock-depth will increase, and then `heap_unlock()` must be
93+
called the same number of times to make the heap available again.
94+
95+
Both `heap_unlock()` and `heap_locked()` return the current lock depth
96+
(after unlocking for the former) as a non-negative integer, with 0 meaning
97+
the heap is not locked.
98+
99+
If the REPL becomes active with the heap locked then it will be forcefully
100+
unlocked.
101+
102+
Note: `heap_locked()` is not enabled on most ports by default,
103+
requires ``MICROPY_PY_MICROPYTHON_HEAP_LOCKED``.
104+
105+
.. CIRCUITPY-CHANGE: REMOVE .. function:: kbd_intr(chr)
106+
107+
Set the character that will raise a `KeyboardInterrupt` exception. By
108+
default this is set to 3 during script execution, corresponding to Ctrl-C.
109+
Passing -1 to this function will disable capture of Ctrl-C, and passing 3
110+
will restore it.
111+
112+
This function can be used to prevent the capturing of Ctrl-C on the
113+
incoming stream of characters that is usually used for the REPL, in case
114+
that stream is used for other purposes.
115+
116+
.. CIRCUITPY-CHANGE: REMOVE .. function:: schedule(func, arg)
117+
118+
Schedule the function *func* to be executed "very soon". The function
119+
is passed the value *arg* as its single argument. "Very soon" means that
120+
the MicroPython runtime will do its best to execute the function at the
121+
earliest possible time, given that it is also trying to be efficient, and
122+
that the following conditions hold:
123+
124+
- A scheduled function will never preempt another scheduled function.
125+
- Scheduled functions are always executed "between opcodes" which means
126+
that all fundamental Python operations (such as appending to a list)
127+
are guaranteed to be atomic.
128+
- A given port may define "critical regions" within which scheduled
129+
functions will never be executed. Functions may be scheduled within
130+
a critical region but they will not be executed until that region
131+
is exited. An example of a critical region is a preempting interrupt
132+
handler (an IRQ).
133+
134+
A use for this function is to schedule a callback from a preempting IRQ.
135+
Such an IRQ puts restrictions on the code that runs in the IRQ (for example
136+
the heap may be locked) and scheduling a function to call later will lift
137+
those restrictions.
138+
139+
On multi-threaded ports, the scheduled function's behaviour depends on
140+
whether the Global Interpreter Lock (GIL) is enabled for the specific port:
141+
142+
- If GIL is enabled, the function can preempt any thread and run in its
143+
context.
144+
- If GIL is disabled, the function will only preempt the main thread and run
145+
in its context.
146+
147+
Note: If `schedule()` is called from a preempting IRQ, when memory
148+
allocation is not allowed and the callback to be passed to `schedule()` is
149+
a bound method, passing this directly will fail. This is because creating a
150+
reference to a bound method causes memory allocation. A solution is to
151+
create a reference to the method in the class constructor and to pass that
152+
reference to `schedule()`. This is discussed in detail here
153+
:ref:`reference documentation <isr_rules>` under "Creation of Python
154+
objects".
155+
156+
There is a finite queue to hold the scheduled functions and `schedule()`
157+
will raise a `RuntimeError` if the queue is full.

examples/natmod/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/natmod/README.md

Lines changed: 0 additions & 74 deletions
This file was deleted.

examples/natmod/deflate/Makefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/natmod/deflate/deflate.c

Lines changed: 0 additions & 70 deletions
This file was deleted.

examples/natmod/features0/Makefile

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)