8000 Merge pull request #44 from kwagyeman/openmv · WeActStudio/micropython@be77733 · GitHub
[go: up one dir, main page]

Skip to content

Commit be77733

Browse files
authored
Merge pull request micropython#44 from kwagyeman/openmv
Update docs
2 parents e0f81c8 + 1ae4636 commit be77733

18 files changed

+1934
-1250
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
# General information about the project.
9797
project = 'MicroPython'
98-
copyright = '2014-2017, Damien P. George, Paul Sokolovsky, OpenMV LLC, and contributors'
98+
copyright = '2014-2018, Damien P. George, Paul Sokolovsky, OpenMV LLC, and contributors'
9999

100100
# The version info for the project you're documenting, acts as replacement for
101101
# |version| and |release|, also used in various other places throughout the

docs/genrst/builtin_types.rst

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Builtin Types
44
=============
5-
Generated Tue 21 Nov 2017 21:31:50 UTC
5+
Generated Sat 28 Apr 2018 19:34:04 UTC
66

77
Exception
88
---------
@@ -70,7 +70,7 @@ Exception in while loop condition may have unexpected line number
7070
Sample code::
7171

7272
l = ["-foo&q 8000 uot;, "-bar"]
73-
73+
7474
i = 0
7575
while l[i][0] == "-":
7676
print("iter")
@@ -90,27 +90,35 @@ Sample code::
9090

9191
.. _cpydiff_types_exception_subclassinit:
9292

93-
Exception.__init__ raises TypeError if overridden and called by subclass
94-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93+
Exception.__init__ method does not exist.
94+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95+
96+
**Cause:** Subclassing native classes is not fully supported in MicroPython.
97+
98+
**Workaround:** Call using ``super()`` instead::
99+
100+
class A(Exception):
101+
def __init__(self):
102+
super().__init__()
95103

96104
Sample code::
97105

98106
class A(Exception):
99107
def __init__(self):
100108
Exception.__init__(self)
101-
109+
102110
a = A()
103111

104-
+-------------+-----------------------------------------------------------+
105-
| CPy output: | uPy output: |
106-
+-------------+-----------------------------------------------------------+
107-
| | :: |
108-
| | |
109-
| | Traceback (most recent call last): |
110-
| | File "<stdin>", line 11, in <module> |
111-
| | File "<stdin>", line 9, in __init__ |
112-
| | TypeError: argument should be a 'Exception' not a 'A' |
113-
+-------------+-----------------------------------------------------------+
112+
+-------------+-------------------------------------------------------------------------+
113+
| CPy output: | uPy output: |
114+
+-------------+-------------------------------------------------------------------------+
115+
| | :: |
116+
| | |
117+
| | Traceback (most recent call last): |
118+
| | File "<stdin>", line 15, in <module> |
119+
| | File "<stdin>", line 13, in __init__ |
120+
| | AttributeError: type object 'Exception' has no attribute '__init__' |
121+
+-------------+-------------------------------------------------------------------------+
114122

115123
bytearray
116124
---------
@@ -221,7 +229,7 @@ Sample code::
221229

222230
class A(int):
223231
__add__ = lambda self, other: A(int(self) + other)
224-
232+
225233
a = A(42)
226234
print(a+a)
227235

@@ -346,14 +354,15 @@ Sample code::
346354
except UnicodeDecodeError:
347355
print('UnicodeDecodeError')
348356

349-
+------------------------+-------------------------+
350-
| CPy output: | uPy output: |
351-
+------------------------+-------------------------+
352-
| :: | :: |
353-
| | |
354-
| UnicodeDecodeError | '\u0840' |
355-
| | Should not get here |
356-
+------------------------+-------------------------+
357+
+------------------------+---------------------------------------------------------+
358+
| CPy output: | uPy output: |
359+
+------------------------+---------------------------------------------------------+
360+
| :: | :: |
361+
| | |
362+
| UnicodeDecodeError | Traceback (most recent call last): |
363+
| | File "<stdin>", line 9, in <module> |
364+
| | NameError: name 'UnicodeDecodeError' is not defined |
365+
+------------------------+---------------------------------------------------------+
357366

358367
.. _cpydiff_types_str_endswith:
359368

@@ -465,7 +474,7 @@ Sample code::
465474

466475
class S(str):
467476
pass
468-
477+
469478
s = S('hello')
470479
print(s == 'hello')
471480

docs/genrst/core_language.rst

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Core Language
44
=============
5-
Generated Tue 21 Nov 2017 21:31:50 UTC
5+
Generated Sat 28 Apr 2018 19:34:04 UTC
66

77
Classes
88
-------
@@ -250,6 +250,59 @@ Sample code::
250250
| Exit | |
251251
+-------------+-------------+
252252

253+
Runtime
254+
-------
255+
256+
.. _cpydiff_core_locals:
257+
258+
Local variables aren't included in locals() result
259+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
260+
261+
**Cause:** MicroPython doesn't maintain symbolic local environment, it is optimized to an array of slots. Thus, local variables can't be accessed by a name.
262+
263+
Sample code::
264+
265+
def test():
266+
val = 2
267+
print(locals())
268+
269+
test()
270+
271+
+----------------+------------------------------------------------------------------------------------------------+
272+
| CPy output: | uPy output: |
273+
+----------------+------------------------------------------------------------------------------------------------+
274+
| :: | :: |
275+
| | |
276+
| {'val': 2} | {'test': <function test at 0x7f014da2e560>, '__name__': '__main__', '__file__': '<stdin>'} |
277+
+----------------+------------------------------------------------------------------------------------------------+
278+
279+
.. _cpydiff_core_locals_eval:
280+
281+
Code running in eval() function doesn't have access to local variables
282+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
283+
284+
**Cause:** MicroPython doesn't maintain symbolic local environment, it is optimized to an array of slots. Thus, local variables can't be accessed by a name. Effectively, ``eval(expr)`` in MicroPython is equivalent to ``eval(expr, globals(), globals())``.
285+
286+
Sample code::
287+
288+
val = 1
289+
290+
def test():
291+
val = 2
292+
print(val)
293+
eval("print(val)")
294+
295+
test()
296+
297+
+-------------+-------------+
298+
| CPy output: | uPy output: |
299+
+-------------+-------------+
300+
| :: | :: |
301+
| | |
302+
| 2 | 2 |
303+
| 2 | 1 |
304+
+-------------+-------------+
305+
253306
import
254307
------
255308

@@ -268,13 +321,13 @@ Sample code::
268321
269322
print(modules.__path__)
270323

271-
+-----------------------------------------------------------------------------+-------------------------------+
272-
| CPy output: | uPy output: |
273-
+-----------------------------------------------------------------------------+-------------------------------+
274-
| :: | :: |
275-
| | |
276-
| ['/home/kwagyeman/GitHub/openmv-doc/micropython/tests/cpydiff/modules'] | ../tests/cpydiff//modules |
277-
+-----------------------------------------------------------------------------+-------------------------------+
324+
+---------------------------------------------------------------------------------------+-------------------------------+
325+
| CPy output: | uPy output: |
326+
+---------------------------------------------------------------------------------------+-------------------------------+
327+
| :: | :: |
328+
| | |
329+
| ['/home/kwagyeman/Documents/GitHub/openmv/src/micropython/tests/cpydiff/modules'] | ../tests/cpydiff//modules |
330+
+---------------------------------------------------------------------------------------+-------------------------------+
278331

279332
.. _cpydiff_core_import_prereg:
280333

docs/genrst/modules.rst

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Modules
44
=======
5-
Generated Tue 21 Nov 2017 21:31:50 UTC
5+
Generated Sat 28 Apr 2018 19:34:04 UTC
66

77
array
88
-----
@@ -70,6 +70,37 @@ Sample code::
7070
| | NotImplementedError: only slices with step=1 (aka None) are supported |
7171
+----------------+---------------------------------------------------------------------------+
7272

73+
builtins
74+
--------
75+
76+
.. _cpydiff_builtin_next_arg2:
77+
78+
Second argument to next() is not implemented
79+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80+
81+
**Cause:** MicroPython is optimised for code space.
82+
83+
**Workaround:** Instead of ``val = next(it, deflt)`` use::
84+
85+
try:
86+
val = next(it)
87+
except StopIteration:
88+
val = deflt
89+
90+
Sample code::
91+
92+
print(next(iter(range(0)), 42))
93+
94+
+-------------+-----------------------------------------------------------------------+
95+
| CPy output: | uPy output: |
96+
+-------------+-----------------------------------------------------------------------+
97+
| :: | :: |
98+
| | |
99+
| 42 | Traceback (most recent call last): |
100+
| | File "<stdin>", line 12, in <module> |
101+
| | TypeError: function takes 1 positional arguments but 2 were given |
102+
+-------------+-----------------------------------------------------------------------+
103+
73104
deque
74105
-----
75106

@@ -86,15 +117,15 @@ Sample code::
86117
D = collections.deque()
87118
print(D)
88119

89-
+---------------+--------------------------------------------------------------+
90-
| CPy output: | uPy output: |
91-
+---------------+--------------------------------------------------------------+
92-
| :: | :: |
93-
| | |
94-
| deque([]) | Traceback (most recent call last): |
95-
| | File "<stdin>", line 8, in <module> |
96-
| | AttributeError: 'module' object has no attribute 'deque' |
97-
+---------------+--------------------------------------------------------------+
120+
+---------------+-----------------------------------------------------------------+
121+
| CPy output: | uPy output: |
122+
+---------------+-----------------------------------------------------------------+
123+
| :: | :: |
124+
| | |
125+
| deque([]) | Traceback (most recent call last): |
126+
| | File "<stdin>", line 8, in <module> |
127+
| | TypeError: function missing 2 required positional arguments |
128+
+---------------+-----------------------------------------------------------------+
98129

99130
json
100131
----

docs/genrst/syntax.rst

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 21 Nov 2017 21:31:50 UTC
5+
Generated Sat 28 Apr 2018 19:34:04 UTC
66

77
Spaces
88
------

docs/library/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ it will fallback to loading the built-in ``ujson`` module.
174174
math.rst
175175
sys.rst
176176
ubinascii.rst
177-
ucollections.rst
178177
uerrno.rst
179178
uhashlib.rst
180179
uheapq.rst
@@ -187,6 +186,7 @@ it will fallback to loading the built-in ``ujson`` module.
187186
ustruct.rst
188187
utime.rst
189188
uzlib.rst
189+
_thread.rst
190190

191191

192192
MicroPython-specific libraries
@@ -274,4 +274,4 @@ the following libraries.
274274
omv.mjpeg.rst
275275
omv.lcd.rst
276276
omv.fir.rst
277-
omv.cpufreq.rst
277+
omv.omv.rst

0 commit comments

Comments
 (0)
0