Skip to content

Commit

Permalink
Merge MicroPython 1.13 into CircuitPython
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed May 5, 2021
2 parents f5f18b2 + b0932fc commit f0bb26d
Show file tree
Hide file tree
Showing 484 changed files with 13,058 additions and 5,214 deletions.
23 changes: 7 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,18 @@ jobs:
run: make -C mpy-cross -j2
- name: Build unix port
run: |
make -C ports/unix deplibs -j2
make -C ports/unix -j2
make -C ports/unix coverage -j2
make -C ports/unix VARIANT=coverage -j2
- name: Test all
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython ./run-tests -j1
working-directory: tests
- name: Print failure info
run: |
shopt -s nullglob;
for exp in *.exp;
do testbase=$(basename $exp .exp);
echo -e "\nFAILURE $testbase";
diff -u $testbase.exp $testbase.out;
done
working-directory: tests
if: failure()
- name: Native Tests
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --emit native
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython ./run-tests -j1 --emit native
working-directory: tests
- name: mpy Tests
run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --via-mpy -d basics float
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
working-directory: tests
- name: Native mpy Tests
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
working-directory: tests
- name: Build mpy-cross.static-raspbian
run: make -C mpy-cross -j2 -f Makefile.static-raspbian
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ build-*/

# Test failure outputs
######################
tests/*.exp
tests/*.out
tests/results/*

# Python cache files
######################
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013-2019 Damien P. George
Copyright (c) 2013-2020 Damien P. George

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# You can set these variables from the command line.
PYTHON = python3
SPHINXOPTS =
SPHINXOPTS = -W --keep-going
SPHINXBUILD = sphinx-build
PAPER =
# path to build the generated docs
Expand Down Expand Up @@ -223,7 +223,7 @@ pseudoxml:
all-source:

locale/circuitpython.pot: all-source
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' > $@
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' > $@

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

.PHONY: check-translate
check-translate:
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
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
$(PYTHON) tools/check_translations.py locale/circuitpython.pot.tmp locale/circuitpython.pot; status=$$?; rm -f locale/circuitpython.pot.tmp; exit $$status

stubs:
Expand Down
8 changes: 4 additions & 4 deletions docs/design_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,10 @@ object instead of the pins themselves. This allows the calling code to provide
any object with the appropriate methods such as an I2C expansion board.

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

Lots of small modules
--------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Full Table of Contents
:caption: MicroPython specific

library/index.rst
reference/glossary.rst

.. toctree::
:maxdepth: 1
Expand Down
4 changes: 2 additions & 2 deletions docs/library/btree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Example::
Functions
---------

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

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

.. method:: btree.__getitem__(key)
btree.get(key, default=None)
btree.get(key, default=None, /)
btree.__setitem__(key, val)
btree.__detitem__(key)
btree.__contains__(key)
Expand Down
16 changes: 9 additions & 7 deletions docs/library/errno.rst
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
:mod:`errno` -- system error codes
:mod:`uerrno` -- system error codes
===================================

.. module:: errno
.. module:: uerrno
:synopsis: system error codes

|see_cpython_module| :mod:`cpython:errno`.
|see_cpython_module| :mod:`python:errno`.

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

Constants
---------

.. data:: EEXIST, EAGAIN, etc.

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

try:
os.mkdir("my_dir")
uos.mkdir("my_dir")
except OSError as exc:
if exc.args[0] == errno.EEXIST:
if exc.args[0] == uerrno.EEXIST:
print("Directory already exists")

.. data:: errorcode

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

>>> print(errno.errorcode[uerrno.EEXIST])
>>> print(uerrno.errorcode[uerrno.EEXIST])
EEXIST
8 changes: 4 additions & 4 deletions docs/library/framebuf.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:mod:`framebuf` --- Frame buffer manipulation
:mod:`framebuf` --- frame buffer manipulation
=============================================

.. include:: ../templates/unsupported_in_circuitpython.inc
Expand Down Expand Up @@ -30,7 +30,7 @@ For example::
Constructors
------------

.. class:: FrameBuffer(buffer, width, height, format, stride=width)
.. class:: FrameBuffer(buffer, width, height, format, stride=width, /)

Construct a FrameBuffer object. The parameters are:

Expand Down Expand Up @@ -132,7 +132,7 @@ Constants

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

Monochrome (1-bit) color format
This defines a mapping where the bits in a byte are horizontally mapped.
Each byte occupies 8 horizontal pixels with bit 7 being the leftmost.
Each byte occupies 8 horizontal pixels with bit 0 being the leftmost.
Subsequent bytes appear at successive horizontal locations until the
rightmost edge is reached. Further bytes are rendered on the next row, one
pixel lower.
Expand Down
1 change: 1 addition & 0 deletions docs/library/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ with the ``u`` prefix dropped:
json.rst
re.rst
sys.rst
uasyncio.rst
uctypes.rst
uselect.rst
uzlib.rst
Expand Down
9 changes: 9 additions & 0 deletions docs/library/micropython.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,26 @@ Functions

.. function:: heap_lock()
.. function:: heap_unlock()
.. function:: heap_locked()

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

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

Both `heap_unlock()` and `heap_locked()` return the current lock depth
(after unlocking for the former) as a non-negative integer, with 0 meaning
the heap is not locked.

If the REPL becomes active with the heap locked then it will be forcefully
unlocked.

Note: `heap_locked()` is not enabled on most ports by default,
requires ``MICROPY_PY_MICROPYTHON_HEAP_LOCKED``.

.. function:: kbd_intr(chr)

Set the character that will raise a `KeyboardInterrupt` exception. By
Expand Down
15 changes: 8 additions & 7 deletions docs/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Functions
string for first position which matches regex (which still may be
0 if regex is anchored).

.. function:: sub(regex_str, replace, string, count=0, flags=0)
.. function:: sub(regex_str, replace, string, count=0, flags=0, /)

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

Note: availability of this function depends on MicroPython port.
Note: availability of this function depends on :term:`MicroPython port`.

.. data:: DEBUG

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


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

.. method:: regex.match(string)
regex.search(string)
regex.sub(replace, string, count=0, flags=0)
regex.sub(replace, string, count=0, flags=0, /)

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

.. method:: regex.split(string, max_split=-1)
.. method:: regex.split(string, max_split=-1, /)

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

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

Note: availability of this method depends on MicroPython port.
Note: availability of this method depends on :term:`MicroPython port`.

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

Note: availability of these methods depends on MicroPython port.
Note: availability of these methods depends on :term:`MicroPython port`.

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

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

Note: availability of this method depends on MicroPython port.
Note: availability of this method depends on :term:`MicroPython port`.
2 changes: 1 addition & 1 deletion docs/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Functions
---------

.. function:: exit(retval=0)
.. function:: exit(retval=0, /)

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

0 comments on commit f0bb26d

Please sign in to comment.