Skip to content

Commit f0bb26d

Browse files
committed
Merge MicroPython 1.13 into CircuitPython
2 parents f5f18b2 + b0932fc commit f0bb26d

File tree

484 files changed

+13058
-5214
lines changed

Some content is hidden

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

484 files changed

+13058
-5214
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,18 @@ jobs:
7171
run: make -C mpy-cross -j2
7272
- name: Build unix port
7373
run: |
74-
make -C ports/unix deplibs -j2
75-
make -C ports/unix -j2
76-
make -C ports/unix coverage -j2
74+
make -C ports/unix VARIANT=coverage -j2
7775
- name: Test all
78-
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1
76+
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython ./run-tests -j1
7977
working-directory: tests
80-
- name: Print failure info
81-
run: |
82-
shopt -s nullglob;
83-
for exp in *.exp;
84-
do testbase=$(basename $exp .exp);
85-
echo -e "\nFAILURE $testbase";
86-
diff -u $testbase.exp $testbase.out;
87-
done
88-
working-directory: tests
89-
if: failure()
9078
- name: Native Tests
91-
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --emit native
79+
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython ./run-tests -j1 --emit native
9280
working-directory: tests
9381
- name: mpy Tests
94-
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --via-mpy -d basics float
82+
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython ./run-tests -j1 --mpy-cross-flags='-mcache-lookup-bc' --via-mpy -d basics float micropython
83+
working-directory: tests
84+
- name: Native mpy Tests
85+
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython ./run-tests -j1 --mpy-cross-flags='-mcache-lookup-bc' --via-mpy --emit native -d basics float micropython
9586
working-directory: tests
9687
- name: Build mpy-cross.static-raspbian
9788
run: make -C mpy-cross -j2 -f Makefile.static-raspbian

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ build-*/
3737

3838
# Test failure outputs
3939
######################
40-
tests/*.exp
41-
tests/*.out
40+
tests/results/*
4241

4342
# Python cache files
4443
######################

LICENSE

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

3-
Copyright (c) 2013-2019 Damien P. George
3+
Copyright (c) 2013-2020 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

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# You can set these variables from the command line.
99
PYTHON = python3
10-
SPHINXOPTS =
10+
SPHINXOPTS = -W --keep-going
1111
SPHINXBUILD = sphinx-build
1212
PAPER =
1313
# path to build the generated docs
@@ -223,7 +223,7 @@ pseudoxml:
223223
all-source:
224224

225225
locale/circuitpython.pot: all-source
226-
find $(TRANSLATE_SOURCES) -type d \( $(TRANSLATE_SOURCES_EXC) \) -prune -o -type f \( -iname "*.c" -o -iname "*.h" \) -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate -o - | sed -e '/"POT-Creation-Date: /d' > $@
226+
find $(TRANSLATE_SOURCES) -type d \( $(TRANSLATE_SOURCES_EXC) \) -prune -o -type f \( -iname "*.c" -o -iname "*.h" \) -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate --keyword=MP_ERROR_TEXT -o - | sed -e '/"POT-Creation-Date: /d' > $@
227227

228228
# Historically, `make translate` updated the .pot file and ran msgmerge.
229229
# However, this was a frequent source of merge conflicts. Weblate can perform
@@ -248,7 +248,7 @@ merge-translate:
248248

249249
.PHONY: check-translate
250250
check-translate:
251-
find $(TRANSLATE_SOURCES) -type d \( $(TRANSLATE_SOURCES_EXC) \) -prune -o -type f \( -iname "*.c" -o -iname "*.h" \) -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate -o circuitpython.pot.tmp -p locale
251+
find $(TRANSLATE_SOURCES) -type d \( $(TRANSLATE_SOURCES_EXC) \) -prune -o -type f \( -iname "*.c" -o -iname "*.h" \) -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate --keyword=MP_ERROR_TEXT -o circuitpython.pot.tmp -p locale
252252
$(PYTHON) tools/check_translations.py locale/circuitpython.pot.tmp locale/circuitpython.pot; status=$$?; rm -f locale/circuitpython.pot.tmp; exit $$status
253253

254254
stubs:

docs/design_guide.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,10 @@ object instead of the pins themselves. This allows the calling code to provide
541541
any object with the appropriate methods such as an I2C expansion board.
542542

543543
Another example is to expect a :py:class:`~digitalio.DigitalInOut` for a pin to
544-
toggle instead of a :py:class:`~microcontroller.Pin` from `board`. Taking in the
545-
:py:class:`~microcontroller.Pin` object alone would limit the driver to pins on
546-
the actual microcontroller instead of pins provided by another driver such as an
547-
IO expander.
544+
toggle instead of a :py:class:`~microcontroller.Pin` from :py:mod:`board`.
545+
Taking in the :py:class:`~microcontroller.Pin` object alone would limit the
546+
driver to pins on the actual microcontroller instead of pins provided by another
547+
driver such as an IO expander.
548548

549549
Lots of small modules
550550
--------------------------------------------------------------------------------

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Full Table of Contents
3636
:caption: MicroPython specific
3737

3838
library/index.rst
39+
reference/glossary.rst
3940

4041
.. toctree::
4142
:maxdepth: 1

docs/library/btree.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Example::
7878
Functions
7979
---------
8080

81-
.. function:: open(stream, \*, flags=0, pagesize=0, cachesize=0, minkeypage=0)
81+
.. function:: open(stream, *, flags=0, pagesize=0, cachesize=0, minkeypage=0)
8282

8383
Open a database from a random-access ``stream`` (like an open file). All
8484
other parameters are optional and keyword-only, and allow to tweak advanced
@@ -118,7 +118,7 @@ Methods
118118
Flush any data in cache to the underlying stream.
119119

120120
.. method:: btree.__getitem__(key)
121-
btree.get(key, default=None)
121+
btree.get(key, default=None, /)
122122
btree.__setitem__(key, val)
123123
btree.__detitem__(key)
124124
btree.__contains__(key)

docs/library/errno.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
:mod:`errno` -- system error codes
1+
:mod:`uerrno` -- system error codes
22
===================================
33

4-
.. module:: errno
4+
.. module:: uerrno
55
:synopsis: system error codes
66

7-
|see_cpython_module| :mod:`cpython:errno`.
7+
|see_cpython_module| :mod:`python:errno`.
88

99
This module provides access to symbolic error codes for `OSError` exception.
10+
A particular inventory of codes depends on :term:`MicroPython port`.
1011

1112
Constants
1213
---------
1314

1415
.. data:: EEXIST, EAGAIN, etc.
1516

1617
Error codes, based on ANSI C/POSIX standard. All error codes start with
17-
"E". Errors are usually accessible as ``exc.args[0]``
18+
"E". As mentioned above, inventory of the codes depends on
19+
:term:`MicroPython port`. Errors are usually accessible as ``exc.args[0]``
1820
where ``exc`` is an instance of `OSError`. Usage example::
1921

2022
try:
21-
os.mkdir("my_dir")
23+
uos.mkdir("my_dir")
2224
except OSError as exc:
23-
if exc.args[0] == errno.EEXIST:
25+
if exc.args[0] == uerrno.EEXIST:
2426
print("Directory already exists")
2527

2628
.. data:: errorcode
2729

2830
Dictionary mapping numeric error codes to strings with symbolic error
2931
code (see above)::
3032

31-
>>> print(errno.errorcode[uerrno.EEXIST])
33+
>>> print(uerrno.errorcode[uerrno.EEXIST])
3234
EEXIST

docs/library/framebuf.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:mod:`framebuf` --- Frame buffer manipulation
1+
:mod:`framebuf` --- frame buffer manipulation
22
=============================================
33

44
.. include:: ../templates/unsupported_in_circuitpython.inc
@@ -30,7 +30,7 @@ For example::
3030
Constructors
3131
------------
3232

33-
.. class:: FrameBuffer(buffer, width, height, format, stride=width)
33+
.. class:: FrameBuffer(buffer, width, height, format, stride=width, /)
3434

3535
Construct a FrameBuffer object. The parameters are:
3636

@@ -132,7 +132,7 @@ Constants
132132

133133
Monochrome (1-bit) color format
134134
This defines a mapping where the bits in a byte are horizontally mapped.
135-
Each byte occupies 8 horizontal pixels with bit 0 being the leftmost.
135+
Each byte occupies 8 horizontal pixels with bit 7 being the leftmost.
136136
Subsequent bytes appear at successive horizontal locations until the
137137
rightmost edge is reached. Further bytes are rendered on the next row, one
138138
pixel lower.
@@ -141,7 +141,7 @@ Constants
141141

142142
Monochrome (1-bit) color format
143143
This defines a mapping where the bits in a byte are horizontally mapped.
144-
Each byte occupies 8 horizontal pixels with bit 7 being the leftmost.
144+
Each byte occupies 8 horizontal pixels with bit 0 being the leftmost.
145145
Subsequent bytes appear at successive horizontal locations until the
146146
rightmost edge is reached. Further bytes are rendered on the next row, one
147147
pixel lower.

docs/library/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ with the ``u`` prefix dropped:
3737
json.rst
3838
re.rst
3939
sys.rst
40+
uasyncio.rst
4041
uctypes.rst
4142
uselect.rst
4243
uzlib.rst

docs/library/micropython.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,26 @@ Functions
7373

7474
.. function:: heap_lock()
7575
.. function:: heap_unlock()
76+
.. function:: heap_locked()
7677

7778
Lock or unlock the heap. When locked no memory allocation can occur and a
7879
`MemoryError` will be raised if any heap allocation is attempted.
80+
`heap_locked()` returns a true value if the heap is currently locked.
7981

8082
These functions can be nested, ie `heap_lock()` can be called multiple times
8183
in a row and the lock-depth will increase, and then `heap_unlock()` must be
8284
called the same number of times to make the heap available again.
8385

86+
Both `heap_unlock()` and `heap_locked()` return the current lock depth
87+
(after unlocking for the former) as a non-negative integer, with 0 meaning
88+
the heap is not locked.
89+
8490
If the REPL becomes active with the heap locked then it will be forcefully
8591
unlocked.
8692

93+
Note: `heap_locked()` is not enabled on most ports by default,
94+
requires ``MICROPY_PY_MICROPYTHON_HEAP_LOCKED``.
95+
8796
.. function:: kbd_intr(chr)
8897

8998
Set the character that will raise a `KeyboardInterrupt` exception. By

docs/library/re.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Functions
124124
string for first position which matches regex (which still may be
125125
0 if regex is anchored).
126126

127-
.. function:: sub(regex_str, replace, string, count=0, flags=0)
127+
.. function:: sub(regex_str, replace, string, count=0, flags=0, /)
128128

129129
Compile *regex_str* and search for it in *string*, replacing all matches
130130
with *replace*, and returning the new string.
@@ -138,11 +138,12 @@ Functions
138138
If *count* is specified and non-zero then substitution will stop after
139139
this many substitutions are made. The *flags* argument is ignored.
140140

141-
Note: availability of this function depends on MicroPython port.
141+
Note: availability of this function depends on :term:`MicroPython port`.
142142

143143
.. data:: DEBUG
144144

145145
Flag value, display debug information about compiled expression.
146+
(Availability depends on :term:`MicroPython port`.)
146147

147148

148149
.. _regex:
@@ -155,14 +156,14 @@ Compiled regular expression. Instances of this class are created using
155156

156157
.. method:: regex.match(string)
157158
regex.search(string)
158-
regex.sub(replace, string, count=0, flags=0)
159+
regex.sub(replace, string, count=0, flags=0, /)
159160

160161
Similar to the module-level functions :meth:`match`, :meth:`search`
161162
and :meth:`sub`.
162163
Using methods is (much) more efficient if the same regex is applied to
163164
multiple strings.
164165

165-
.. method:: regex.split(string, max_split=-1)
166+
.. method:: regex.split(string, max_split=-1, /)
166167

167168
Split a *string* using regex. If *max_split* is given, it specifies
168169
maximum number of splits to perform. Returns list of strings (there
@@ -183,7 +184,7 @@ to the replacement function in `sub()`.
183184

184185
Return a tuple containing all the substrings of the groups of the match.
185186

186-
Note: availability of this method depends on MicroPython port.
187+
Note: availability of this method depends on :term:`MicroPython port`.
187188

188189
.. method:: match.start([index])
189190
match.end([index])
@@ -192,10 +193,10 @@ to the replacement function in `sub()`.
192193
substring group that was matched. *index* defaults to the entire
193194
group, otherwise it will select a group.
194195

195-
Note: availability of these methods depends on MicroPython port.
196+
Note: availability of these methods depends on :term:`MicroPython port`.
196197

197198
.. method:: match.span([index])
198199

199200
Returns the 2-tuple ``(match.start(index), match.end(index))``.
200201

201-
Note: availability of this method depends on MicroPython port.
202+
Note: availability of this method depends on :term:`MicroPython port`.

docs/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Functions
1212
---------
1313

14-
.. function:: exit(retval=0)
14+
.. function:: exit(retval=0, /)
1515

1616
Terminate current program with a given exit code. Underlyingly, this
1717
function raise as `SystemExit` exception. If an argument is given, its

0 commit comments

Comments
 (0)