Skip to content

Commit 9259ad6

Browse files
committed
Update documentation
1 parent a2dcc5f commit 9259ad6

File tree

221 files changed

+6524
-4499
lines changed

Some content is hidden

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

221 files changed

+6524
-4499
lines changed

docs/_sources/differences/python_37.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ Changes to built-in modules:
105105

106106
.. rubric:: Notes
107107

108-
.. [#ftimenanosec] Only :func:`time.time_ns` is implemented.
108+
.. [#ftimenanosec] Only :func:`time.time_ns` is implemented.

docs/_sources/genrst/builtin_types.rst.txt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Builtin types
44
=============
5-
Generated Tue 05 Mar 2024 02:12:06 UTC
5+
Generated Tue 23 Jul 2024 04:50:56 UTC
66

77
Exception
88
---------
@@ -423,6 +423,37 @@ Sample code::
423423
| [5, 2, 6, 4] | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
424424
+------------------+---------------------------------------------------------------------+
425425

426+
memoryview
427+
----------
428+
429+
.. _cpydiff_types_memoryview_invalid:
430+
431+
memoryview can become invalid if its target is resized
432+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
433+
434+
**Cause:** CPython prevents a ``bytearray`` or ``io.bytesIO`` object from changing size while there is a ``memoryview`` object that references it. MicroPython requires the programmer to manually ensure that an object is not resized while any ``memoryview`` references it.
435+
436+
In the worst case scenario, resizing an object which is the target of a memoryview can cause the memoryview(s) to reference invalid freed memory (a use-after-free bug) and corrupt the MicroPython runtime.
437+
438+
**Workaround:** Do not change the size of any ``bytearray`` or ``io.bytesIO`` object that has a ``memoryview`` assigned to it.
439+
440+
Sample code::
441+
442+
b = bytearray(b"abcdefg")
443+
m = memoryview(b)
444+
b.extend(b"hijklmnop")
445+
print(b, bytes(m))
446+
447+
+----------------------------------------------------------------------+---------------------------------------------------------------------+
448+
| CPy output: | uPy output: |
449+
+----------------------------------------------------------------------+---------------------------------------------------------------------+
450+
| :: | :: |
451+
| | |
452+
| Traceback (most recent call last): | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
453+
| File "<stdin>", line 11, in <module> | |
454+
| BufferError: Existing exports of data: object cannot be re-sized | |
455+
+----------------------------------------------------------------------+---------------------------------------------------------------------+
456+
426457
str
427458
---
428459

docs/_sources/genrst/core_language.rst.txt

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Core language
44
=============
5-
Generated Tue 05 Mar 2024 02:12:06 UTC
5+
Generated Tue 23 Jul 2024 04:50:56 UTC
66

77
.. _cpydiff_core_fstring_concat:
88

@@ -165,6 +165,50 @@ Sample code::
165165
| Foo | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
166166
+-------------+---------------------------------------------------------------------+
167167

168+
.. _cpydiff_core_class_name_mangling:
169+
170+
Private Class Members name mangling is not implemented
171+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172+
173+
**Cause:** The MicroPython compiler does not implement name mangling for private class members.
174+
175+
**Workaround:** Avoid using or having a collision with global names, by adding a unique prefix to the private class member name manually.
176+
177+
Sample code::
178+
179+
180+
181+
def __print_string(string):
182+
print(string)
183+
184+
185+
class Foo:
186+
def __init__(self, string):
187+
self.string = string
188+
189+
def do_print(self):
190+
__print_string(self.string)
191+
192+
193+
example_string = "Example String to print."
194+
195+
class_item = Foo(example_string)
196+
print(class_item.string)
197+
198+
class_item.do_print()
199+
200+
+---------------------------------------------------------+---------------------------------------------------------------------+
201+
| CPy output: | uPy output: |
202+
+---------------------------------------------------------+---------------------------------------------------------------------+
203+
| :: | :: |
204+
| | |
205+
| Example String to print. | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
206+
| Traceback (most recent call last): | |
207+
| File "<stdin>", line 26, in <module> | |
208+
| File "<stdin>", line 18, in do_print | |
209+
| NameError: name '_Foo__print_string' is not defined | |
210+
+---------------------------------------------------------+---------------------------------------------------------------------+
211+
168212
.. _cpydiff_core_class_supermultiple:
169213

170214
When inheriting from multiple classes super() only calls one class

docs/_sources/genrst/modules.rst.txt

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,41 @@
22
33
Modules
44
=======
5-
Generated Tue 05 Mar 2024 02:12:06 UTC
5+
Generated Tue 23 Jul 2024 04:50:56 UTC
6+
7+
.. Preamble section inserted into generated output
8+
9+
Positional-only Parameters
10+
--------------------------
11+
12+
To save code size, many functions that accept keyword arguments in CPython only accept positional arguments in MicroPython.
13+
14+
MicroPython marks positional-only parameters in the same way as CPython, by inserting a ``/`` to mark the end of the positional parameters. Any function whose signature ends in ``/`` takes *only* positional arguments. For more details, see `PEP 570 <https://peps.python.org/pep-0570/>`_.
15+
16+
Example
17+
~~~~~~~
18+
19+
For example, in CPython 3.4 this is the signature of the constructor ``socket.socket``::
20+
21+
socket.socket(family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None)
22+
23+
However, the signature documented in :func:`MicroPython<socket.socket>` is::
24+
25+
socket(af=AF_INET, type=SOCK_STREAM, proto=IPPROTO_TCP, /)
26+
27+
The ``/`` at the end of the parameters indicates that they are all positional-only in MicroPython. The following code works in CPython but not in most MicroPython ports::
28+
29+
import socket
30+
s = socket.socket(type=socket.SOCK_DGRAM)
31+
32+
MicroPython will raise an exception::
33+
34+
TypeError: function doesn't take keyword arguments
35+
36+
The following code will work in both CPython and MicroPython::
37+
38+
import socket
39+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
640

741
array
842
-----
@@ -281,7 +315,7 @@ Sample code::
281315
+-------------------------+---------------------------------------------------------------------+
282316
| :: | :: |
283317
| | |
284-
| 4275605868765694853 | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
318+
| 3720919278385122334 | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
285319
+-------------------------+---------------------------------------------------------------------+
286320

287321
.. _cpydiff_modules_random_randint:
@@ -307,7 +341,7 @@ Sample code::
307341
+-----------------------------------------------+---------------------------------------------------------------------+
308342
| :: | :: |
309343
| | |
310-
| x=340282366920938463463374607431768211455 | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
344+
| x=340282366920938463463374607431768211456 | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
311345
+-----------------------------------------------+---------------------------------------------------------------------+
312346

313347
struct

docs/_sources/genrst/syntax.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Syntax
44
======
5-
Generated Tue 05 Mar 2024 02:12:06 UTC
5+
Generated Tue 23 Jul 2024 04:50:56 UTC
66

77
.. _cpydiff_syntax_arg_unpacking:
88

docs/_sources/library/asyncio.rst.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ class ThreadSafeFlag
149149

150150
Create a new flag which can be used to synchronise a task with code running
151151
outside the asyncio loop, such as other threads, IRQs, or scheduler
152-
callbacks. Flags start in the cleared state. The class does not currently
153-
work under the Unix build of MicroPython.
152+
callbacks. Flags start in the cleared state.
154153

155154
.. method:: ThreadSafeFlag.set()
156155

docs/_sources/library/bluetooth.rst.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ Broadcaster Role (Advertiser)
312312
in all broadcasts, and *resp_data* is send in reply to an active scan.
313313

314314
**Note:** if *adv_data* (or *resp_data*) is ``None``, then the data passed
315-
to the previous call to ``gap_advertise`` will be re-used. This allows a
315+
to the previous call to ``gap_advertise`` will be reused. This allows a
316316
broadcaster to resume advertising with just ``gap_advertise(interval_us)``.
317317
To clear the advertising payload pass an empty ``bytes``, i.e. ``b''``.
318318

@@ -722,7 +722,7 @@ Pairing and bonding
722722
and ``_IRQ_SET_SECRET`` events.
723723

724724
**Note:** This is currently only supported when using the NimBLE stack on
725-
STM32 and Unix (not ESP32).
725+
ESP32, STM32 and Unix.
726726

727727
.. method:: BLE.gap_pair(conn_handle, /)
728728

docs/_sources/library/collections.rst.txt

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,47 @@ Classes
1818
appends and pops from either side of the deque. New deques are created
1919
using the following arguments:
2020

21-
- *iterable* must be the empty tuple, and the new deque is created empty.
21+
- *iterable* is an iterable used to populate the deque when it is
22+
created. It can be an empty tuple or list to create a deque that
23+
is initially empty.
2224

2325
- *maxlen* must be specified and the deque will be bounded to this
2426
maximum length. Once the deque is full, any new items added will
2527
discard items from the opposite end.
2628

2729
- The optional *flags* can be 1 to check for overflow when adding items.
2830

29-
As well as supporting `bool` and `len`, deque objects have the following
30-
methods:
31+
Deque objects support `bool`, `len`, iteration and subscript load and store.
32+
They also have the following methods:
3133

3234
.. method:: deque.append(x)
3335

3436
Add *x* to the right side of the deque.
35-
Raises IndexError if overflow checking is enabled and there is no more room left.
37+
Raises ``IndexError`` if overflow checking is enabled and there is
38+
no more room in the queue.
39+
40+
.. method:: deque.appendleft(x)
41+
42+
Add *x* to the left side of the deque.
43+
Raises ``IndexError`` if overflow checking is enabled and there is
44+
no more room in the queue.
45+
46+
.. method:: deque.pop()
47+
48+
Remove and return an item from the right side of the deque.
49+
Raises ``IndexError`` if no items are present.
3650

3751
.. method:: deque.popleft()
3852

3953
Remove and return an item from the left side of the deque.
40-
Raises IndexError if no items are present.
54+
Raises ``IndexError`` if no items are present.
55+
56+
.. method:: deque.extend(iterable)
57+
58+
Extend the deque by appending all the items from *iterable* to
59+
the right of the deque.
60+
Raises ``IndexError`` if overflow checking is enabled and there is
61+
no more room in the deque.
4162

4263
.. function:: namedtuple(name, fields)
4364

docs/_sources/library/index.rst.txt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ the following libraries.
9898
btree.rst
9999
cryptolib.rst
100100
deflate.rst
101-
framebuf.rst
102101
machine.rst
103102
micropython.rst
104-
neopixel.rst
105103
network.rst
104+
openamp.rst
106105
uctypes.rst
107106
mutex.rst
108107
uping.rst
109108
urequests.rst
109+
vfs.rst
110110

111111
Libraries specific to the OpenMV Cam
112112
------------------------------------
@@ -120,11 +120,10 @@ The following libraries are specific to the OpenMV Cam.
120120
stm.rst
121121
omv.sensor.rst
122122
omv.image.rst
123-
omv.tf.rst
123+
omv.ml.rst
124124
omv.gif.rst
125125
omv.mjpeg.rst
126126
omv.audio.rst
127-
omv.micro_speech.rst
128127
omv.display.rst
129128
omv.fir.rst
130129
omv.tv.rst
@@ -177,12 +176,6 @@ Examples scripts are located in OpenMV IDE under the ``IMU Shield`` examples fol
177176

178177
Examples scripts are located in OpenMV IDE under the ``Motor Shield`` examples folder.
179178

180-
:mod:`lsm6dsox` --- `lsm6dsox Driver <https://github.com/openmv/openmv/blob/master/scripts/libraries/lsm6dsox.py>`_
181-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
182-
183-
.. module:: lsm6dsox
184-
:synopsis: lsm6dsox Driver
185-
186179
:mod:`modbus` --- `modbus protocol library <https://github.com/openmv/openmv/blob/master/scripts/libraries/modbus.py>`_
187180
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188181

docs/_sources/library/machine.ADCBlock.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Constructors
2626

2727
Access the ADC peripheral identified by *id*, which may be an integer
2828
or string.
29-
29+
3030
The *bits* argument, if given, sets the resolution in bits of the
3131
conversion process. If not specified then the previous or default
3232
resolution is used.

0 commit comments

Comments
 (0)