summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-08-14 18:21:55 +1000
committerDamien George <damien.p.george@gmail.com>2017-08-14 18:21:55 +1000
commit25e24b2c3c63e035b4c145f743f5cd7b02a23fc0 (patch)
tree2b90e3e19f0e81256cdceb5168c9ded42ca4ddd7
parent022d6a979851461432fdec6c6855a73d462baf4d (diff)
parent869cdcfdfc860b1177baf9b0f8818915ba54f3f5 (diff)
Merge tag 'v1.9.1' into parse-bytecode
Fixes for stmhal USB mass storage, lwIP bindings and VFS regressions This release provides an important fix for the USB mass storage device in the stmhal port by implementing the SCSI SYNCHRONIZE_CACHE command, which is now require by some Operating Systems. There are also fixes for the lwIP bindings to improve non-blocking sockets and error codes. The VFS has some regressions fixed including the ability to statvfs the root. All changes are listed below. py core: - modbuiltins: add core-provided version of input() function - objstr: catch case of negative "maxsplit" arg to str.rsplit() - persistentcode: allow to compile with complex numbers disabled - objstr: allow to compile with obj-repr D, and unicode disabled - modsys: allow to compile with obj-repr D and PY_ATTRTUPLE disabled - provide mp_decode_uint_skip() to help reduce stack usage - makeqstrdefs.py: make script run correctly with Python 2.6 - objstringio: if created from immutable object, follow copy on write policy extmod: - modlwip: connect: for non-blocking mode, return EINPROGRESS - modlwip: fix error codes for duplicate calls to connect() - modlwip: accept: fix error code for non-blocking mode - vfs: allow to statvfs the root directory - vfs: allow "buffering" and "encoding" args to VFS's open() - modframebuf: fix signed/unsigned comparison pendantic warning lib: - libm: use isfinite instead of finitef, for C99 compatibility - utils/interrupt_char: remove support for KBD_EXCEPTION disabled tests: - basics/string_rsplit: add tests for negative "maxsplit" argument - float: convert "sys.exit()" to "raise SystemExit" - float/builtin_float_minmax: PEP8 fixes - basics: convert "sys.exit()" to "raise SystemExit" - convert remaining "sys.exit()" to "raise SystemExit" unix port: - convert to use core-provided version of built-in import() - Makefile: replace references to make with $(MAKE) windows port: - convert to use core-provided version of built-in import() qemu-arm port: - Makefile: adjust object-file lists to get correct dependencies - enable micropython.mem_*() functions to allow more tests stmhal port: - boards: enable DAC for NUCLEO_F767ZI board - add support for NUCLEO_F446RE board - pass USB handler as parameter to allow more than one USB handler - usb: use local USB handler variable in Start-of-Frame handler - usb: make state for USB device private to top-level USB driver - usbdev: for MSC implement SCSI SYNCHRONIZE_CACHE command - convert from using stmhal's input() to core provided version cc3200 port: - convert from using stmhal's input() to core provided version teensy port: - convert from using stmhal's input() to core provided version esp8266 port: - Makefile: replace references to make with $(MAKE) - Makefile: add clean-modules target - convert from using stmhal's input() to core provided version zephyr port: - modusocket: getaddrinfo: Fix mp_obj_len() usage - define MICROPY_PY_SYS_PLATFORM (to "zephyr") - machine_pin: use native Zephyr types for Zephyr API calls docs: - machine.Pin: remove out_value() method - machine.Pin: add on() and off() methods - esp8266: consistently replace Pin.high/low methods with .on/off - esp8266/quickref: polish Pin.on()/off() examples - network: move confusingly-named cc3200 Server class to its reference - uos: deconditionalize, remove minor port-specific details - uos: move cc3200 port legacy VFS mounting functions to its ref doc - machine: sort machine classes in logical order, not alphabetically - network: first step to describe standard network class interface examples: - embedding: use core-provided KeyboardInterrupt object
-rw-r--r--cc3200/README.md2
-rw-r--r--cc3200/application.mk1
-rw-r--r--cc3200/mpconfigport.h2
-rwxr-xr-xdocs/conf.py2
-rw-r--r--docs/esp8266/quickref.rst6
-rw-r--r--docs/esp8266/tutorial/pins.rst4
-rw-r--r--docs/esp8266/tutorial/repl.rst9
-rw-r--r--docs/library/btree.rst2
-rw-r--r--docs/library/machine.Pin.rst14
-rw-r--r--docs/library/machine.SD.rst2
-rw-r--r--docs/library/machine.UART.rst2
-rw-r--r--docs/library/machine.rst16
-rw-r--r--docs/library/network.rst119
-rw-r--r--docs/library/uhashlib.rst4
-rw-r--r--docs/library/uos.rst47
-rw-r--r--docs/library/utime.rst4
-rw-r--r--docs/pyboard/general.rst4
-rw-r--r--docs/sphinx_selective_exclude/README.md2
-rw-r--r--docs/sphinx_selective_exclude/modindex_exclude.py2
-rw-r--r--docs/wipy/general.rst62
-rw-r--r--esp8266/Makefile11
-rw-r--r--esp8266/README.md2
-rw-r--r--esp8266/machine_rtc.c2
-rw-r--r--esp8266/mpconfigport.h2
-rw-r--r--examples/conwaylife.py4
-rw-r--r--examples/embedding/Makefile.upylib2
-rw-r--r--examples/embedding/README.md2
-rw-r--r--examples/embedding/mpconfigport_minimal.h2
-rw-r--r--extmod/modframebuf.c2
-rw-r--r--extmod/modlwip.c14
-rw-r--r--extmod/modwebsocket.c2
-rw-r--r--extmod/vfs.c29
-rw-r--r--lib/libm/sf_ldexp.c2
-rw-r--r--lib/timeutils/timeutils.c2
-rw-r--r--lib/utils/interrupt_char.c12
-rw-r--r--lib/utils/stdout_helpers.c2
-rw-r--r--py/asmthumb.c2
-rw-r--r--py/bc.c10
-rw-r--r--py/bc.h1
-rw-r--r--py/builtinimport.c4
-rw-r--r--py/compile.c4
-rw-r--r--py/makeqstrdefs.py28
-rw-r--r--py/misc.h2
-rw-r--r--py/mkenv.mk2
-rw-r--r--py/modbuiltins.c32
-rw-r--r--py/modsys.c6
-rw-r--r--py/mpconfig.h8
-rw-r--r--py/mperrno.h2
-rw-r--r--py/obj.c2
-rw-r--r--py/objfun.c22
-rw-r--r--py/objgenerator.c7
-rw-r--r--py/objstr.c13
-rw-r--r--py/objstringio.c30
-rw-r--r--py/objstringio.h2
-rw-r--r--py/persistentcode.c10
-rw-r--r--py/py.mk2
-rw-r--r--py/ringbuf.h2
-rw-r--r--py/stream.c2
-rw-r--r--py/vm.c17
-rw-r--r--qemu-arm/Makefile35
-rw-r--r--qemu-arm/README.md2
-rw-r--r--qemu-arm/mpconfigport.h4
-rw-r--r--stmhal/Makefile1
-rw-r--r--stmhal/adc.c2
-rw-r--r--stmhal/boards/NUCLEO_F446RE/mpconfigboard.h64
-rw-r--r--stmhal/boards/NUCLEO_F446RE/mpconfigboard.mk4
-rw-r--r--stmhal/boards/NUCLEO_F446RE/pins.csv72
-rw-r--r--stmhal/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h413
-rw-r--r--stmhal/boards/NUCLEO_F767ZI/mpconfigboard.h2
-rw-r--r--stmhal/boards/NUCLEO_F767ZI/stm32f7xx_hal_conf.h2
-rw-r--r--stmhal/input.c44
-rw-r--r--stmhal/mpconfigport.h2
-rw-r--r--stmhal/storage.c2
-rw-r--r--stmhal/usb.c4
-rw-r--r--stmhal/usb.h1
-rw-r--r--stmhal/usbd_cdc_interface.c20
-rw-r--r--stmhal/usbd_hid_interface.c20
-rw-r--r--stmhal/usbd_hid_interface.h2
-rw-r--r--stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h8
-rw-r--r--stmhal/usbdev/class/inc/usbd_msc_scsi.h2
-rw-r--r--stmhal/usbdev/class/src/usbd_cdc_msc_hid.c8
-rw-r--r--stmhal/usbdev/class/src/usbd_msc_scsi.c12
-rw-r--r--teensy/Makefile1
-rw-r--r--teensy/mpconfigport.h2
-rw-r--r--tests/basics/array1.py3
-rw-r--r--tests/basics/array_add.py3
-rw-r--r--tests/basics/array_construct.py3
-rw-r--r--tests/basics/array_construct2.py3
-rw-r--r--tests/basics/array_construct_endian.py3
-rw-r--r--tests/basics/array_intbig.py3
-rw-r--r--tests/basics/array_micropython.py3
-rw-r--r--tests/basics/attrtuple1.py3
-rw-r--r--tests/basics/builtin_delattr.py3
-rw-r--r--tests/basics/builtin_help.py3
-rw-r--r--tests/basics/builtin_minmax.py3
-rw-r--r--tests/basics/builtin_override.py3
-rw-r--r--tests/basics/builtin_pow3.py3
-rw-r--r--tests/basics/builtin_pow3_intbig.py3
-rw-r--r--tests/basics/builtin_property.py3
-rw-r--r--tests/basics/builtin_range_attrs.py3
-rw-r--r--tests/basics/builtin_reversed.py3
-rw-r--r--tests/basics/builtin_sorted.py3
-rw-r--r--tests/basics/bytearray_construct_array.py3
-rw-r--r--tests/basics/bytearray_construct_endian.py3
-rw-r--r--tests/basics/bytearray_slice_assign.py3
-rw-r--r--tests/basics/bytes_add_array.py3
-rw-r--r--tests/basics/bytes_add_endian.py3
-rw-r--r--tests/basics/bytes_compare_array.py3
-rw-r--r--tests/basics/bytes_construct_array.py3
-rw-r--r--tests/basics/bytes_construct_endian.py3
-rw-r--r--tests/basics/bytes_partition.py3
-rw-r--r--tests/basics/class_delattr_setattr.py3
-rw-r--r--tests/basics/class_descriptor.py3
-rw-r--r--tests/basics/class_new.py3
-rw-r--r--tests/basics/class_store_class.py3
-rw-r--r--tests/basics/class_super_object.py3
-rw-r--r--tests/basics/dict_fromkeys2.py3
-rw-r--r--tests/basics/enumerate.py3
-rw-r--r--tests/basics/errno1.py3
-rw-r--r--tests/basics/filter.py3
-rw-r--r--tests/basics/frozenset1.py3
-rw-r--r--tests/basics/frozenset_add.py3
-rw-r--r--tests/basics/frozenset_binop.py3
-rw-r--r--tests/basics/frozenset_copy.py3
-rw-r--r--tests/basics/frozenset_difference.py3
-rw-r--r--tests/basics/frozenset_set.py3
-rw-r--r--tests/basics/fun_error2.py3
-rw-r--r--tests/basics/gc1.py3
-rw-r--r--tests/basics/memoryview1.py3
-rw-r--r--tests/basics/memoryview2.py3
-rw-r--r--tests/basics/memoryview_gc.py3
-rw-r--r--tests/basics/memoryview_intbig.py3
-rw-r--r--tests/basics/namedtuple1.py5
-rw-r--r--tests/basics/object_dict.py3
-rw-r--r--tests/basics/object_new.py3
-rw-r--r--tests/basics/op_error_memoryview.py3
-rw-r--r--tests/basics/ordereddict1.py3
-rw-r--r--tests/basics/ordereddict_eq.py3
-rw-r--r--tests/basics/parser.py3
-rw-r--r--tests/basics/set_type.py3
-rw-r--r--tests/basics/slice_attrs.py3
-rw-r--r--tests/basics/special_methods2.py3
-rw-r--r--tests/basics/string_center.py3
-rw-r--r--tests/basics/string_partition.py3
-rw-r--r--tests/basics/string_rpartition.py3
-rw-r--r--tests/basics/string_rsplit.py4
-rw-r--r--tests/basics/string_splitlines.py3
-rw-r--r--tests/basics/struct1.py3
-rw-r--r--tests/basics/struct1_intbig.py3
-rw-r--r--tests/basics/struct2.py3
-rw-r--r--tests/basics/struct_micropython.py3
-rw-r--r--tests/basics/subclass_classmethod.py3
-rw-r--r--tests/basics/sys1.py2
-rw-r--r--tests/basics/try_reraise2.py2
-rw-r--r--tests/basics/zip.py3
-rw-r--r--tests/extmod/btree1.py3
-rw-r--r--tests/extmod/framebuf1.py3
-rw-r--r--tests/extmod/framebuf16.py3
-rw-r--r--tests/extmod/framebuf4.py3
-rw-r--r--tests/extmod/machine1.py3
-rw-r--r--tests/extmod/machine_pinbase.py3
-rw-r--r--tests/extmod/machine_pulse.py3
-rw-r--r--tests/extmod/machine_signal.py3
-rw-r--r--tests/extmod/time_ms_us.py3
-rw-r--r--tests/extmod/ubinascii_a2b_base64.py3
-rw-r--r--tests/extmod/ubinascii_b2a_base64.py3
-rw-r--r--tests/extmod/ubinascii_crc32.py6
-rw-r--r--tests/extmod/ubinascii_hexlify.py3
-rw-r--r--tests/extmod/ubinascii_micropython.py3
-rw-r--r--tests/extmod/ubinascii_unhexlify.py3
-rw-r--r--tests/extmod/uctypes_32bit_intbig.py3
-rw-r--r--tests/extmod/uctypes_array_assign_le.py3
-rw-r--r--tests/extmod/uctypes_array_assign_native_le.py4
-rw-r--r--tests/extmod/uctypes_array_assign_native_le_intbig.py4
-rw-r--r--tests/extmod/uctypes_bytearray.py3
-rw-r--r--tests/extmod/uctypes_le.py3
-rw-r--r--tests/extmod/uctypes_le_float.py3
-rw-r--r--tests/extmod/uctypes_native_float.py3
-rw-r--r--tests/extmod/uctypes_native_le.py4
-rw-r--r--tests/extmod/uctypes_print.py3
-rw-r--r--tests/extmod/uctypes_ptr_le.py4
-rw-r--r--tests/extmod/uctypes_ptr_native_le.py4
-rw-r--r--tests/extmod/uctypes_sizeof.py3
-rw-r--r--tests/extmod/uctypes_sizeof_native.py3
-rw-r--r--tests/extmod/uhashlib_sha1.py5
-rw-r--r--tests/extmod/uhashlib_sha256.py3
-rw-r--r--tests/extmod/uheapq1.py3
-rw-r--r--tests/extmod/ujson_dumps.py3
-rw-r--r--tests/extmod/ujson_dumps_extra.py3
-rw-r--r--tests/extmod/ujson_dumps_float.py3
-rw-r--r--tests/extmod/ujson_load.py3
-rw-r--r--tests/extmod/ujson_loads.py3
-rw-r--r--tests/extmod/ujson_loads_float.py3
-rw-r--r--tests/extmod/urandom_basic.py3
-rw-r--r--tests/extmod/urandom_extra.py6
-rw-r--r--tests/extmod/ure1.py3
-rw-r--r--tests/extmod/ure_debug.py3
-rw-r--r--tests/extmod/ure_error.py3
-rw-r--r--tests/extmod/ure_group.py3
-rw-r--r--tests/extmod/ure_namedclass.py3
-rw-r--r--tests/extmod/ure_split.py3
-rw-r--r--tests/extmod/ure_split_empty.py3
-rw-r--r--tests/extmod/ure_split_notimpl.py3
-rw-r--r--tests/extmod/ussl_basic.py3
-rw-r--r--tests/extmod/utimeq1.py3
-rw-r--r--tests/extmod/utimeq_stable.py3
-rw-r--r--tests/extmod/uzlib_decompio.py3
-rw-r--r--tests/extmod/uzlib_decompio_gz.py3
-rw-r--r--tests/extmod/uzlib_decompress.py3
-rw-r--r--tests/extmod/vfs_basic.py8
-rw-r--r--tests/extmod/vfs_basic.py.exp4
-rw-r--r--tests/extmod/vfs_fat_fileio1.py7
-rw-r--r--tests/extmod/vfs_fat_fileio2.py7
-rw-r--r--tests/extmod/vfs_fat_more.py7
-rw-r--r--tests/extmod/vfs_fat_oldproto.py7
-rw-r--r--tests/extmod/vfs_fat_ramdisk.py7
-rw-r--r--tests/extmod/websocket_basic.py3
-rw-r--r--tests/float/array_construct.py3
-rw-r--r--tests/float/builtin_float_minmax.py39
-rw-r--r--tests/float/bytearray_construct.py3
-rw-r--r--tests/float/bytes_construct.py3
-rw-r--r--tests/float/cmath_fun.py3
-rw-r--r--tests/float/cmath_fun_special.py3
-rw-r--r--tests/float/float_array.py3
-rw-r--r--tests/float/float_struct.py3
-rw-r--r--tests/float/math_fun.py3
-rw-r--r--tests/float/math_fun_bool.py3
-rw-r--r--tests/float/math_fun_int.py3
-rw-r--r--tests/float/math_fun_intbig.py3
-rw-r--r--tests/float/math_fun_special.py3
-rw-r--r--tests/io/buffered_writer.py3
-rw-r--r--tests/io/bytesio_cow.py20
-rw-r--r--tests/io/open_append.py3
-rw-r--r--tests/io/open_plus.py3
-rw-r--r--tests/io/resource_stream.py2
-rw-r--r--tests/io/write_ext.py3
-rw-r--r--tests/jni/list.py3
-rw-r--r--tests/jni/object.py3
-rw-r--r--tests/jni/system_out.py3
-rw-r--r--tests/micropython/heapalloc_bytesio.py3
-rw-r--r--tests/micropython/heapalloc_bytesio2.py20
-rw-r--r--tests/micropython/heapalloc_bytesio2.py.exp1
-rw-r--r--tests/micropython/heapalloc_iter.py3
-rw-r--r--tests/micropython/heapalloc_traceback.py3
-rw-r--r--tests/micropython/heapalloc_traceback.py.exp2
-rw-r--r--tests/micropython/kbd_intr.py3
-rw-r--r--tests/micropython/schedule.py3
-rw-r--r--tests/misc/non_compliant.py3
-rw-r--r--tests/misc/print_exception.py2
-rw-r--r--tests/misc/recursive_data.py3
-rw-r--r--tests/misc/recursive_iternext.py3
-rw-r--r--tests/misc/sys_exc_info.py2
-rw-r--r--tests/pyb/can.py5
-rw-r--r--tests/pyb/dac.py3
-rw-r--r--tests/pyb/pyb_f405.py3
-rw-r--r--tests/pyb/pyb_f411.py3
-rw-r--r--tests/thread/stress_aes.py2
-rw-r--r--tests/unix/extra_coverage.py3
-rw-r--r--tests/unix/ffi_callback.py3
-rw-r--r--tests/unix/ffi_float.py3
-rw-r--r--tests/unix/ffi_float2.py5
-rw-r--r--tests/wipy/uart.py2
-rw-r--r--tools/insert-usb-ids.py2
-rwxr-xr-xtools/pyboard.py2
-rw-r--r--unix/Makefile10
-rw-r--r--unix/input.c43
-rw-r--r--unix/modsocket.c2
-rw-r--r--unix/mpconfigport.h2
-rw-r--r--unix/mphalport.h13
-rw-r--r--windows/mpconfigport.h2
-rw-r--r--windows/windows_mphal.c2
-rw-r--r--zephyr/machine_pin.c4
-rw-r--r--zephyr/modusocket.c3
-rw-r--r--zephyr/modutime.c2
-rw-r--r--zephyr/mpconfigport.h2
275 files changed, 1324 insertions, 742 deletions
diff --git a/cc3200/README.md b/cc3200/README.md
index 753fd450a..53cad3ba0 100644
--- a/cc3200/README.md
+++ b/cc3200/README.md
@@ -138,7 +138,7 @@ If `WIPY_IP`, `WIPY_USER` or `WIPY_PWD` are omitted the default values (the ones
## Regarding old revisions of the CC3200-LAUNCHXL
First silicon (pre-release) revisions of the CC3200 had issues with the ram blocks, and MicroPython cannot run
-there. Make sure to use a **v4.1 (or higer) LAUNCHXL board** when trying this port, otherwise it won't work.
+there. Make sure to use a **v4.1 (or higher) LAUNCHXL board** when trying this port, otherwise it won't work.
### Note regarding FileZilla
diff --git a/cc3200/application.mk b/cc3200/application.mk
index 5d25424e1..1f54b764b 100644
--- a/cc3200/application.mk
+++ b/cc3200/application.mk
@@ -151,7 +151,6 @@ APP_LIB_SRC_C = $(addprefix lib/,\
APP_STM_SRC_C = $(addprefix stmhal/,\
bufhelper.c \
- input.c \
irq.c \
pybstdio.c \
)
diff --git a/cc3200/mpconfigport.h b/cc3200/mpconfigport.h
index 4d19900ae..4bd583a4b 100644
--- a/cc3200/mpconfigport.h
+++ b/cc3200/mpconfigport.h
@@ -80,6 +80,7 @@
#define MICROPY_VFS_FAT (1)
#define MICROPY_PY_ASYNC_AWAIT (0)
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
+#define MICROPY_PY_BUILTINS_INPUT (1)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_TEXT cc3200_help_text
#ifndef DEBUG
@@ -142,7 +143,6 @@
// extra built in names to add to the global namespace
#define MICROPY_PORT_BUILTINS \
- { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, \
// extra built in modules to add to the list of known ones
diff --git a/docs/conf.py b/docs/conf.py
index e813f2383..8fb53e890 100755
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -99,7 +99,7 @@ copyright = '2014-2017, Damien P. George, Paul Sokolovsky, and contributors'
# The short X.Y version.
version = '1.9'
# The full version, including alpha/beta/rc tags.
-release = '1.9'
+release = '1.9.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/docs/esp8266/quickref.rst b/docs/esp8266/quickref.rst
index 5ff33e02b..ccf6365c8 100644
--- a/docs/esp8266/quickref.rst
+++ b/docs/esp8266/quickref.rst
@@ -107,9 +107,9 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
from machine import Pin
p0 = Pin(0, Pin.OUT) # create output pin on GPIO0
- p0.high() # set pin to high
- p0.low() # set pin to low
- p0.value(1) # set pin to high
+ p0.on() # set pin to "on" (high) level
+ p0.off() # set pin to "off" (low) level
+ p0.value(1) # set pin to on/high
p2 = Pin(2, Pin.IN) # create input pin on GPIO2
print(p2.value()) # get value, 0 or 1
diff --git a/docs/esp8266/tutorial/pins.rst b/docs/esp8266/tutorial/pins.rst
index a44f40d3a..cd45c83cd 100644
--- a/docs/esp8266/tutorial/pins.rst
+++ b/docs/esp8266/tutorial/pins.rst
@@ -35,8 +35,8 @@ Then set its value using::
Or::
- >>> pin.low()
- >>> pin.high()
+ >>> pin.off()
+ >>> pin.on()
External interrupts
-------------------
diff --git a/docs/esp8266/tutorial/repl.rst b/docs/esp8266/tutorial/repl.rst
index 21e889c9a..ba64fcccb 100644
--- a/docs/esp8266/tutorial/repl.rst
+++ b/docs/esp8266/tutorial/repl.rst
@@ -101,11 +101,12 @@ turn it on and off using the following code::
>>> import machine
>>> pin = machine.Pin(2, machine.Pin.OUT)
- >>> pin.high()
- >>> pin.low()
+ >>> pin.on()
+ >>> pin.off()
-Note that ``high`` might turn the LED off and ``low`` might turn it on (or vice
-versa), depending on how the LED is wired on your board.
+Note that ``on`` method of a Pin might turn the LED off and ``off`` might
+turn it on (or vice versa), depending on how the LED is wired on your board.
+To resolve this, machine.Signal class is provided.
Line editing
~~~~~~~~~~~~
diff --git a/docs/library/btree.rst b/docs/library/btree.rst
index aebcbc160..bd7890586 100644
--- a/docs/library/btree.rst
+++ b/docs/library/btree.rst
@@ -69,7 +69,7 @@ Functions
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
- paramters of the database operation (most users will not need them):
+ parameters of the database operation (most users will not need them):
* `flags` - Currently unused.
* `cachesize` - Suggested maximum memory cache size in bytes. For a
diff --git a/docs/library/machine.Pin.rst b/docs/library/machine.Pin.rst
index 2efd84688..05ceb4ad3 100644
--- a/docs/library/machine.Pin.rst
+++ b/docs/library/machine.Pin.rst
@@ -146,18 +146,20 @@ Methods
When setting the value this method returns ``None``.
-.. method:: Pin.out_value()
-
- Return the value stored in the output buffer of a pin, regardless of its mode.
-
- Not all ports implement this method.
-
.. method:: Pin.__call__([x])
Pin objects are callable. The call method provides a (fast) shortcut to set
and get the value of the pin. It is equivalent to Pin.value([x]).
See :meth:`Pin.value` for more details.
+.. method:: Pin.on()
+
+ Set pin to "1" output level.
+
+.. method:: Pin.off()
+
+ Set pin to "0" output level.
+
.. method:: Pin.mode([mode])
Get or set the pin mode.
diff --git a/docs/library/machine.SD.rst b/docs/library/machine.SD.rst
index 0eb024602..608e95831 100644
--- a/docs/library/machine.SD.rst
+++ b/docs/library/machine.SD.rst
@@ -34,7 +34,7 @@ Methods
.. method:: SD.init(id=0, pins=('GP10', 'GP11', 'GP15'))
- Enable the SD card. In order to initalize the card, give it a 3-tuple:
+ Enable the SD card. In order to initialize the card, give it a 3-tuple:
``(clk_pin, cmd_pin, dat0_pin)``.
.. method:: SD.deinit()
diff --git a/docs/library/machine.UART.rst b/docs/library/machine.UART.rst
index f9c8efef7..64ff28e1a 100644
--- a/docs/library/machine.UART.rst
+++ b/docs/library/machine.UART.rst
@@ -16,7 +16,7 @@ UART objects can be created and initialised using::
uart = UART(1, 9600) # init with given baudrate
uart.init(9600, bits=8, parity=None, stop=1) # init with given parameters
-Supported paramters differ on a board:
+Supported parameters differ on a board:
Pyboard: Bits can be 7, 8 or 9. Stop can be 1 or 2. With `parity=None`,
only 8 and 9 bits are supported. With parity enabled, only 7 and 8 bits
diff --git a/docs/library/machine.rst b/docs/library/machine.rst
index c2c6b83fd..7ea7f565e 100644
--- a/docs/library/machine.rst
+++ b/docs/library/machine.rst
@@ -145,13 +145,13 @@ Classes
.. toctree::
:maxdepth: 1
- machine.I2C.rst
machine.Pin.rst
machine.Signal.rst
- machine.RTC.rst
+ machine.UART.rst
machine.SPI.rst
+ machine.I2C.rst
+ machine.RTC.rst
machine.Timer.rst
- machine.UART.rst
machine.WDT.rst
.. only:: port_wipy
@@ -159,12 +159,12 @@ Classes
.. toctree::
:maxdepth: 1
- machine.ADC.rst
- machine.I2C.rst
machine.Pin.rst
- machine.RTC.rst
- machine.SD.rst
+ machine.UART.rst
machine.SPI.rst
+ machine.I2C.rst
+ machine.RTC.rst
machine.Timer.rst
- machine.UART.rst
machine.WDT.rst
+ machine.ADC.rst
+ machine.SD.rst
diff --git a/docs/library/network.rst b/docs/library/network.rst
index 251e68c76..27fa0dcb2 100644
--- a/docs/library/network.rst
+++ b/docs/library/network.rst
@@ -14,14 +14,20 @@ module.
For example::
- # configure a specific network interface
+ # connect/ show IP config a specific network interface
# see below for examples of specific drivers
import network
+ import utime
nic = network.Driver(...)
+ if not nic.isconnected():
+ nic.connect()
+ print("Waiting for connection...")
+ while not nic.isconnected():
+ utime.sleep(1)
print(nic.ifconfig())
- # now use socket as usual
- import socket
+ # now use usocket as usual
+ import usocket as socket
addr = socket.getaddrinfo('micropython.org', 80)[0][-1]
s = socket.socket()
s.connect(addr)
@@ -29,51 +35,102 @@ For example::
data = s.recv(1000)
s.close()
-.. only:: port_wipy
+Common network adapter interface
+================================
- .. _network.Server:
+This section describes an (implied) abstract base class for all network
+interface classes implemented by different ports of MicroPython for
+different hardware. This means that MicroPython does not actually
+provide `AbstractNIC` class, but any actual NIC class, as described
+in the following sections, implements methods as described here.
- class Server
- ============
+.. class:: AbstractNIC(id=None, ...)
- The ``Server`` class controls the behaviour and the configuration of the FTP and telnet
- services running on the WiPy. Any changes performed using this class' methods will
- affect both.
+Instantiate a network interface object. Parameters are network interface
+dependent. If there are more than one interface of the same type, the first
+parameter should be `id`.
- Example::
+ .. method:: active([is_active])
- import network
- server = network.Server()
- server.deinit() # disable the server
- # enable the server again with new settings
- server.init(login=('user', 'password'), timeout=600)
+ Activate ("up") or deactivate ("down") the network interface, if
+ a boolean argument is passed. Otherwise, query current state if
+ no argument is provided. Most other methods require an active
+ interface (behavior of calling them on inactive interface is
+ undefined).
- Constructors
- ------------
+ .. method:: connect([service_id, key=None, \*, ...])
- .. class:: network.Server(id, ...)
+ Connect the interface to a network. This method is optional, and
+ available only for interfaces which are not "always connected".
+ If no parameters are given, connect to the default (or the only)
+ service. If a single parameter is given, it is the primary identifier
+ of a service to connect to. It may be accompanied by a key
+ (password) required to access said service. There can be further
+ arbitrary keyword-only parameters, depending on the networking medium
+ type and/or particular device. Parameters can be used to: a)
+ specify alternative service identifer types; b) provide additional
+ connection parameters. For various medium types, there are different
+ sets of predefined/recommended parameters, among them:
- Create a server instance, see ``init`` for parameters of initialization.
+ * WiFi: `bssid` keyword to connect by BSSID (MAC address) instead
+ of access point name
- Methods
- -------
+ .. method:: disconnect()
+
+ Disconnect from network.
+
+ .. method:: isconnected()
+
+ Returns ``True`` if connected to network, otherwise returns ``False``.
+
+ .. method:: scan(\*, ...)
+
+ Scan for the available network services/connections. Returns a
+ list of tuples with discovered service parameters. For various
+ network media, there are different variants of predefined/
+ recommended tuple formats, among them:
+
+ * WiFi: (ssid, bssid, channel, RSSI, authmode, hidden). There
+ may be further fields, specific to a particular device.
- .. method:: server.init(\*, login=('micro', 'python'), timeout=300)
+ The function may accept additional keyword arguments to filter scan
+ results (e.g. scan for a particular service, on a particular channel,
+ for services of a particular set, etc.), and to affect scan
+ duration and other parameters. Where possible, parameter names
+ should match those in connect().
- Init (and effectively start the server). Optionally a new ``user``, ``password``
- and ``timeout`` (in seconds) can be passed.
+ .. method:: status()
- .. method:: server.deinit()
+ Return detailed status of the interface, values are dependent
+ on the network medium/technology.
- Stop the server
+ .. method:: ifconfig([(ip, subnet, gateway, dns)])
- .. method:: server.timeout([timeout_in_seconds])
+ Get/set IP-level network interface parameters: IP address, subnet mask,
+ gateway and DNS server. When called with no arguments, this method returns
+ a 4-tuple with the above information. To set the above values, pass a
+ 4-tuple with the required information. For example::
- Get or set the server timeout.
+ nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
- .. method:: server.isrunning()
+ .. method:: config('param')
+ config(param=value, ...)
- Returns ``True`` if the server is running, ``False`` otherwise.
+ Get or set general network interface parameters. These methods allow to work
+ with additional parameters beyond standard IP configuration (as dealt with by
+ ``ifconfig()``). These include network-specific and hardware-specific
+ parameters and status values. For setting parameters, the keyword argument
+ syntax should be used, and multiple parameters can be set at once. For
+ querying, a parameter name should be quoted as a string, and only one
+ parameter can be queried at a time::
+
+ # Set WiFi access point name (formally known as ESSID) and WiFi channel
+ ap.config(essid='My AP', channel=11)
+ # Query params one by one
+ print(ap.config('essid'))
+ print(ap.config('channel'))
+ # Extended status information also available this way
+ print(sta.config('rssi'))
.. only:: port_pyboard
diff --git a/docs/library/uhashlib.rst b/docs/library/uhashlib.rst
index cd0216dae..6b9a764ba 100644
--- a/docs/library/uhashlib.rst
+++ b/docs/library/uhashlib.rst
@@ -15,11 +15,11 @@ be implemented:
* SHA1 - A previous generation algorithm. Not recommended for new usages,
but SHA1 is a part of number of Internet standards and existing
- applications, so boards targetting network connectivity and
+ applications, so boards targeting network connectivity and
interoperatiability will try to provide this.
* MD5 - A legacy algorithm, not considered cryptographically secure. Only
- selected boards, targetting interoperatibility with legacy applications,
+ selected boards, targeting interoperatibility with legacy applications,
will offer this.
Constructors
diff --git a/docs/library/uos.rst b/docs/library/uos.rst
index d1f83d2cc..3d0aa46c7 100644
--- a/docs/library/uos.rst
+++ b/docs/library/uos.rst
@@ -4,28 +4,9 @@
.. module:: uos
:synopsis: basic "operating system" services
-The ``os`` module contains functions for filesystem access and ``urandom``
+The ``uos`` module contains functions for filesystem access and ``urandom``
function.
-Port specifics
---------------
-
-The filesystem has ``/`` as the root directory and the
-available physical drives are accessible from here. They are currently:
-
- ``/flash`` -- the internal flash filesystem
-
- ``/sd`` -- the SD card (if it exists)
-
-.. only:: port_pyboard
-
- On boot up, the current directory is ``/flash`` if no SD card is inserted,
- otherwise it is ``/sd``.
-
-.. only:: port_wipy
-
- On boot up, the current directory is ``/flash``.
-
Functions
---------
@@ -106,26 +87,8 @@ Functions
Return a bytes object with n random bytes. Whenever possible, it is
generated by the hardware random number generator.
-.. only:: port_wipy
-
- .. function:: mount(block_device, mount_point, \*, readonly=False)
-
- Mounts a block device (like an ``SD`` object) in the specified mount
- point. Example::
-
- os.mount(sd, '/sd')
-
- .. function:: unmount(path)
-
- Unmounts a previously mounted block device from the given path.
-
- .. function:: mkfs(block_device or path)
-
- Formats the specified path, must be either ``/flash`` or ``/sd``.
- A block device can also be passed like an ``SD`` object before
- being mounted.
-
- .. function:: dupterm(stream_object)
+.. function:: dupterm(stream_object)
- Duplicate the terminal (the REPL) on the passed stream-like object.
- The given object must at least implement the ``.read()`` and ``.write()`` methods.
+ Duplicate or switch MicroPython terminal (the REPL) on the passed stream-like
+ object. The given object must implement the `.readinto()` and `.write()`
+ methods. If ``None`` is passed, previously set redirection is cancelled.
diff --git a/docs/library/utime.rst b/docs/library/utime.rst
index 871f6c678..f3a067cde 100644
--- a/docs/library/utime.rst
+++ b/docs/library/utime.rst
@@ -146,8 +146,8 @@ Functions
too distant inbetween, see below). The function returns **signed** value in the range
[``-TICKS_PERIOD/2`` .. ``TICKS_PERIOD/2-1``] (that's a typical range definition for
two's-complement signed binary integers). If the result is negative, it means that
- ``ticks1`` occured earlier in time than ``ticks2``. Otherwise, it means that
- ``ticks1`` occured after ``ticks2``. This holds ``only`` if ``ticks1`` and ``ticks2``
+ ``ticks1`` occurred earlier in time than ``ticks2``. Otherwise, it means that
+ ``ticks1`` occurred after ``ticks2``. This holds ``only`` if ``ticks1`` and ``ticks2``
are apart from each other for no more than ``TICKS_PERIOD/2-1`` ticks. If that does
not hold, incorrect result will be returned. Specifically, if two tick values are
apart for ``TICKS_PERIOD/2-1`` ticks, that value will be returned by the function.
diff --git a/docs/pyboard/general.rst b/docs/pyboard/general.rst
index 48e014644..1d040f6cc 100644
--- a/docs/pyboard/general.rst
+++ b/docs/pyboard/general.rst
@@ -10,7 +10,9 @@ is inserted into the slot, it is available as ``/sd``.
When the pyboard boots up, it needs to choose a filesystem to boot from. If
there is no SD card, then it uses the internal filesystem ``/flash`` as the boot
-filesystem, otherwise, it uses the SD card ``/sd``.
+filesystem, otherwise, it uses the SD card ``/sd``. After the boot, the current
+directory is set to one of the directories above.
+
If needed, you can prevent the use of the SD card by creating an empty file
called ``/flash/SKIPSD``. If this file exists when the pyboard boots
up then the SD card will be skipped and the pyboard will always boot from the
diff --git a/docs/sphinx_selective_exclude/README.md b/docs/sphinx_selective_exclude/README.md
index cc9725c21..dab140739 100644
--- a/docs/sphinx_selective_exclude/README.md
+++ b/docs/sphinx_selective_exclude/README.md
@@ -66,7 +66,7 @@ index for PDF, just the same as for HTML.
search_auto_exclude
-------------------
-Even if you exclude soem documents from toctree:: using only::
+Even if you exclude some documents from toctree:: using only::
directive, they will be indexed for full-text search, so user may
find them and get confused. This plugin follows very simple idea
that if you didn't include some documents in the toctree, then
diff --git a/docs/sphinx_selective_exclude/modindex_exclude.py b/docs/sphinx_selective_exclude/modindex_exclude.py
index 18b49cc80..bf8db795e 100644
--- a/docs/sphinx_selective_exclude/modindex_exclude.py
+++ b/docs/sphinx_selective_exclude/modindex_exclude.py
@@ -2,7 +2,7 @@
# This is a Sphinx documentation tool extension which allows to
# exclude some Python modules from the generated indexes. Modules
# are excluded both from "modindex" and "genindex" index tables
-# (in the latter case, all members of a module are exlcuded).
+# (in the latter case, all members of a module are excluded).
# To control exclusion, set "modindex_exclude" variable in Sphinx
# conf.py to the list of modules to exclude. Note: these should be
# modules (as defined by py:module directive, not just raw filenames).
diff --git a/docs/wipy/general.rst b/docs/wipy/general.rst
index 8b9b91c53..f28edb4e4 100644
--- a/docs/wipy/general.rst
+++ b/docs/wipy/general.rst
@@ -53,7 +53,7 @@ which is stored within the external serial flash memory. If a micro SD card
is hooked-up and mounted, it will be available as well.
When the WiPy starts up, it always boots from the ``boot.py`` located in the
-``/flash`` file system.
+``/flash`` file system. On boot up, the current directory is ``/flash``.
The file system is accessible via the native FTP server running in the WiPy.
Open your FTP client of choice and connect to:
@@ -323,3 +323,63 @@ Unrelated function in machine module
this function is not called then the default file main.py will be executed.
It only makes sense to call this function from within boot.py.
+
+Adhoc way to control telnet/FTP server via network module
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``Server`` class controls the behaviour and the configuration of the FTP and telnet
+services running on the WiPy. Any changes performed using this class' methods will
+affect both.
+
+Example::
+
+ import network
+ server = network.Server()
+ server.deinit() # disable the server
+ # enable the server again with new settings
+ server.init(login=('user', 'password'), timeout=600)
+
+.. class:: network.Server(id, ...)
+
+ Create a server instance, see ``init`` for parameters of initialization.
+
+.. method:: server.init(\*, login=('micro', 'python'), timeout=300)
+
+ Init (and effectively start the server). Optionally a new ``user``, ``password``
+ and ``timeout`` (in seconds) can be passed.
+
+.. method:: server.deinit()
+
+ Stop the server
+
+.. method:: server.timeout([timeout_in_seconds])
+
+ Get or set the server timeout.
+
+.. method:: server.isrunning()
+
+ Returns ``True`` if the server is running, ``False`` otherwise.
+
+Adhoc VFS-like support
+~~~~~~~~~~~~~~~~~~~~~~
+
+WiPy doesn't implement full MicroPython VFS support, instead following
+functions are defined in ``uos`` module:
+
+.. function:: mount(block_device, mount_point, \*, readonly=False)
+
+ Mounts a block device (like an ``SD`` object) in the specified mount
+ point. Example::
+
+ os.mount(sd, '/sd')
+
+.. function:: unmount(path)
+
+ Unmounts a previously mounted block device from the given path.
+
+.. function:: mkfs(block_device or path)
+
+ Formats the specified path, must be either ``/flash`` or ``/sd``.
+ A block device can also be passed like an ``SD`` object before
+ being mounted.
+
diff --git a/esp8266/Makefile b/esp8266/Makefile
index a3da9d398..ff35689f4 100644
--- a/esp8266/Makefile
+++ b/esp8266/Makefile
@@ -94,7 +94,6 @@ SRC_C = \
STM_SRC_C = $(addprefix stmhal/,\
pybstdio.c \
- input.c \
)
EXTMOD_SRC_C = $(addprefix extmod/,\
@@ -233,7 +232,11 @@ axtls: $(BUILD)/libaxtls.a
$(BUILD)/libaxtls.a:
cd ../lib/axtls; cp config/upyconfig config/.config
- cd ../lib/axtls; make oldconfig -B
- cd ../lib/axtls; make clean
- cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)" AR="$(AR)" CFLAGS_EXTRA="$(CFLAGS_XTENSA) -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=3072"
+ cd ../lib/axtls; $(MAKE) oldconfig -B
+ cd ../lib/axtls; $(MAKE) clean
+ cd ../lib/axtls; $(MAKE) all CC="$(CC)" LD="$(LD)" AR="$(AR)" CFLAGS_EXTRA="$(CFLAGS_XTENSA) -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=3072"
cp ../lib/axtls/_stage/libaxtls.a $@
+
+clean-modules:
+ git clean -f -d modules
+ rm -f build/frozen*.c
diff --git a/esp8266/README.md b/esp8266/README.md
index 897bb4737..d717d26fe 100644
--- a/esp8266/README.md
+++ b/esp8266/README.md
@@ -100,7 +100,7 @@ programming).
__WiFi__
-Initally, the device configures itself as a WiFi access point (AP).
+Initially, the device configures itself as a WiFi access point (AP).
- ESSID: MicroPython-xxxxxx (x’s are replaced with part of the MAC address).
- Password: micropythoN (note the upper-case N).
- IP address of the board: 192.168.4.1.
diff --git a/esp8266/machine_rtc.c b/esp8266/machine_rtc.c
index 019b705ba..b17bcb261 100644
--- a/esp8266/machine_rtc.c
+++ b/esp8266/machine_rtc.c
@@ -93,7 +93,7 @@ void pyb_rtc_set_us_since_2000(uint64_t nowus) {
int64_t delta = nowus - (((uint64_t)rtc_last_ticks * cal) >> 12);
// As the calibration value jitters quite a bit, to make the
- // clock at least somewhat practially usable, we need to store it
+ // clock at least somewhat practically usable, we need to store it
system_rtc_mem_write(MEM_CAL_ADDR, &cal, sizeof(cal));
system_rtc_mem_write(MEM_DELTA_ADDR, &delta, sizeof(delta));
};
diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h
index c286bdcdd..483f93d02 100644
--- a/esp8266/mpconfigport.h
+++ b/esp8266/mpconfigport.h
@@ -39,6 +39,7 @@
#define MICROPY_PY_BUILTINS_SLICE (1)
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
#define MICROPY_PY_BUILTINS_PROPERTY (1)
+#define MICROPY_PY_BUILTINS_INPUT (1)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_TEXT esp_help_text
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
@@ -147,7 +148,6 @@ void *esp_native_code_commit(void*, size_t);
// extra built in names to add to the global namespace
#define MICROPY_PORT_BUILTINS \
- { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
// extra built in modules to add to the list of known ones
diff --git a/examples/conwaylife.py b/examples/conwaylife.py
index f99796175..323f42e85 100644
--- a/examples/conwaylife.py
+++ b/examples/conwaylife.py
@@ -8,7 +8,7 @@ lcd.light(1)
def conway_step():
for x in range(128): # loop over x coordinates
for y in range(32): # loop over y coordinates
- # count number of neigbours
+ # count number of neighbours
num_neighbours = (lcd.get(x - 1, y - 1) +
lcd.get(x, y - 1) +
lcd.get(x + 1, y - 1) +
@@ -25,7 +25,7 @@ def conway_step():
if self and not (2 <= num_neighbours <= 3):
lcd.pixel(x, y, 0) # not enough, or too many neighbours: cell dies
elif not self and num_neighbours == 3:
- lcd.pixel(x, y, 1) # exactly 3 neigbours around an empty cell: cell is born
+ lcd.pixel(x, y, 1) # exactly 3 neighbours around an empty cell: cell is born
# randomise the start
def conway_rand():
diff --git a/examples/embedding/Makefile.upylib b/examples/embedding/Makefile.upylib
index 873c0fd34..4663ad30a 100644
--- a/examples/embedding/Makefile.upylib
+++ b/examples/embedding/Makefile.upylib
@@ -170,7 +170,7 @@ SRC_QSTR_AUTO_DEPS +=
include $(MPTOP)/py/mkrules.mk
# Value of configure's --host= option (required for cross-compilation).
-# Deduce it from CROSS_COMPILE by default, but can be overriden.
+# Deduce it from CROSS_COMPILE by default, but can be overridden.
ifneq ($(CROSS_COMPILE),)
CROSS_COMPILE_HOST = --host=$(patsubst %-,%,$(CROSS_COMPILE))
else
diff --git a/examples/embedding/README.md b/examples/embedding/README.md
index 989ce1fc8..804dfede6 100644
--- a/examples/embedding/README.md
+++ b/examples/embedding/README.md
@@ -18,7 +18,7 @@ Building the example is as simple as running:
It's worth to trace what's happening behind the scenes though:
1. As a first step, a MicroPython library is built. This is handled by a
-seperate makefile, Makefile.upylib. It is more or less complex, but the
+separate makefile, Makefile.upylib. It is more or less complex, but the
good news is that you won't need to change anything in it, just use it
as is, the main Makefile shows how. What may require editing though is
a MicroPython configuration file. MicroPython is highly configurable, so
diff --git a/examples/embedding/mpconfigport_minimal.h b/examples/embedding/mpconfigport_minimal.h
index d16827fa3..87c87fa97 100644
--- a/examples/embedding/mpconfigport_minimal.h
+++ b/examples/embedding/mpconfigport_minimal.h
@@ -34,6 +34,7 @@
#define MICROPY_MEM_STATS (0)
#define MICROPY_DEBUG_PRINTERS (0)
#define MICROPY_READER_POSIX (1)
+#define MICROPY_KBD_EXCEPTION (1)
#define MICROPY_HELPER_REPL (1)
#define MICROPY_HELPER_LEXER_UNIX (1)
#define MICROPY_ENABLE_SOURCE_LINE (0)
@@ -91,7 +92,6 @@ extern const struct _mp_obj_module_t mp_module_os;
{ MP_OBJ_NEW_QSTR(MP_QSTR_uos), (mp_obj_t)&mp_module_os }, \
#define MICROPY_PORT_ROOT_POINTERS \
- mp_obj_t keyboard_interrupt_obj;
//////////////////////////////////////////
// Do not change anything beyond this line
diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c
index b8e84fe1c..a07392675 100644
--- a/extmod/modframebuf.c
+++ b/extmod/modframebuf.c
@@ -449,7 +449,7 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
int cx1 = x1;
for (int cx0 = x0; cx0 < x0end; ++cx0) {
color = getpixel(source, cx1, y1);
- if (color != key) {
+ if (color != (uint32_t)key) {
setpixel(self, cx0, y0, color);
}
++cx1;
diff --git a/extmod/modlwip.c b/extmod/modlwip.c
index c72849cf9..01190d200 100644
--- a/extmod/modlwip.c
+++ b/extmod/modlwip.c
@@ -373,7 +373,7 @@ STATIC err_t _lwip_tcp_recv(void *arg, struct tcp_pcb *tcpb, struct pbuf *p, err
}
/*******************************************************************************/
-// Functions for socket send/recieve operations. Socket send/recv and friends call
+// Functions for socket send/receive operations. Socket send/recv and friends call
// these to do the work.
// Helper function for send/sendto to handle UDP packets.
@@ -732,7 +732,9 @@ STATIC mp_obj_t lwip_socket_accept(mp_obj_t self_in) {
// accept incoming connection
if (socket->incoming.connection == NULL) {
- if (socket->timeout != -1) {
+ if (socket->timeout == 0) {
+ mp_raise_OSError(MP_EAGAIN);
+ } else if (socket->timeout != -1) {
for (mp_uint_t retries = socket->timeout / 100; retries--;) {
mp_hal_delay_ms(100);
if (socket->incoming.connection != NULL) break;
@@ -800,12 +802,12 @@ STATIC mp_obj_t lwip_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
case MOD_NETWORK_SOCK_STREAM: {
if (socket->state != STATE_NEW) {
if (socket->state == STATE_CONNECTED) {
- mp_raise_OSError(MP_EALREADY);
+ mp_raise_OSError(MP_EISCONN);
} else {
- mp_raise_OSError(MP_EINPROGRESS);
+ mp_raise_OSError(MP_EALREADY);
}
}
- // Register our recieve callback.
+ // Register our receive callback.
tcp_recv(socket->pcb.tcp, _lwip_tcp_recv);
socket->state = STATE_CONNECTING;
err = tcp_connect(socket->pcb.tcp, &dest, port, _lwip_tcp_connected);
@@ -822,7 +824,7 @@ STATIC mp_obj_t lwip_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
if (socket->state != STATE_CONNECTING) break;
}
if (socket->state == STATE_CONNECTING) {
- mp_raise_OSError(MP_ETIMEDOUT);
+ mp_raise_OSError(MP_EINPROGRESS);
}
} else {
while (socket->state == STATE_CONNECTING) {
diff --git a/extmod/modwebsocket.c b/extmod/modwebsocket.c
index 8200ea708..9e17d6a6d 100644
--- a/extmod/modwebsocket.c
+++ b/extmod/modwebsocket.c
@@ -132,7 +132,7 @@ STATIC mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int
self->buf_pos = 0;
self->to_recv = to_recv;
- self->msg_sz = sz; // May be overriden by FRAME_OPT
+ self->msg_sz = sz; // May be overridden by FRAME_OPT
if (to_recv != 0) {
self->state = FRAME_OPT;
} else {
diff --git a/extmod/vfs.c b/extmod/vfs.c
index f158bd387..3bdce80db 100644
--- a/extmod/vfs.c
+++ b/extmod/vfs.c
@@ -228,11 +228,14 @@ mp_obj_t mp_vfs_umount(mp_obj_t mnt_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_umount_obj, mp_vfs_umount);
+// Note: buffering and encoding args are currently ignored
mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_file, ARG_mode, ARG_encoding };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} },
+ { MP_QSTR_buffering, MP_ARG_INT, {.u_int = -1} },
+ { MP_QSTR_encoding, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
};
// parse args
@@ -421,6 +424,32 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_stat_obj, mp_vfs_stat);
mp_obj_t mp_vfs_statvfs(mp_obj_t path_in) {
mp_obj_t path_out;
mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
+ if (vfs == MP_VFS_ROOT) {
+ // statvfs called on the root directory, see if there's anything mounted there
+ for (vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
+ if (vfs->len == 1) {
+ break;
+ }
+ }
+
+ // If there's nothing mounted at root then return a mostly-empty tuple
+ if (vfs == NULL) {
+ mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL));
+
+ // fill in: bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flags
+ for (int i = 0; i <= 8; ++i) {
+ t->items[i] = MP_OBJ_NEW_SMALL_INT(0);
+ }
+
+ // Put something sensible in f_namemax
+ t->items[9] = MP_OBJ_NEW_SMALL_INT(MICROPY_ALLOC_PATH_MAX);
+
+ return MP_OBJ_FROM_PTR(t);
+ }
+
+ // VFS mounted at root so delegate the call to it
+ path_out = MP_OBJ_NEW_QSTR(MP_QSTR__slash_);
+ }
return mp_vfs_proxy_call(vfs, MP_QSTR_statvfs, 1, &path_out);
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_statvfs_obj, mp_vfs_statvfs);
diff --git a/lib/libm/sf_ldexp.c b/lib/libm/sf_ldexp.c
index 32a134eea..a0941df9f 100644
--- a/lib/libm/sf_ldexp.c
+++ b/lib/libm/sf_ldexp.c
@@ -32,7 +32,7 @@
float value; int exp;
#endif
{
- if(!finitef(value)||value==(float)0.0) return value;
+ if(!isfinite(value)||value==(float)0.0) return value;
value = scalbnf(value,exp);
//if(!finitef(value)||value==(float)0.0) errno = ERANGE;
return value;
diff --git a/lib/timeutils/timeutils.c b/lib/timeutils/timeutils.c
index 0af39a295..06915f25a 100644
--- a/lib/timeutils/timeutils.c
+++ b/lib/timeutils/timeutils.c
@@ -165,7 +165,7 @@ mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday,
//
// tm_tomorrow = list(time.localtime())
// tm_tomorrow[2] += 1 # Adds 1 to mday
- // tomorrow = time.mktime(tm_tommorrow)
+ // tomorrow = time.mktime(tm_tomorrow)
//
// And not have to worry about all the weird overflows.
//
diff --git a/lib/utils/interrupt_char.c b/lib/utils/interrupt_char.c
index 344db88c7..fca0f95b5 100644
--- a/lib/utils/interrupt_char.c
+++ b/lib/utils/interrupt_char.c
@@ -27,28 +27,24 @@
#include "py/obj.h"
#include "py/mpstate.h"
+#if MICROPY_KBD_EXCEPTION
+
int mp_interrupt_char;
void mp_hal_set_interrupt_char(int c) {
if (c != -1) {
- #if MICROPY_KBD_EXCEPTION
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
- #else
- mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception));
- #endif
}
mp_interrupt_char = c;
}
void mp_keyboard_interrupt(void) {
- #if MICROPY_KBD_EXCEPTION
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
- #else
- MP_STATE_VM(mp_pending_exception) = MP_STATE_PORT(mp_kbd_exception);
- #endif
#if MICROPY_ENABLE_SCHEDULER
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
}
#endif
}
+
+#endif
diff --git a/lib/utils/stdout_helpers.c b/lib/utils/stdout_helpers.c
index 5f7a17d32..3de119757 100644
--- a/lib/utils/stdout_helpers.c
+++ b/lib/utils/stdout_helpers.c
@@ -9,7 +9,7 @@
* implementation below can be used.
*/
-// Send "cooked" string of given length, where every occurance of
+// Send "cooked" string of given length, where every occurrence of
// LF character is replaced with CR LF.
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
while (len--) {
diff --git a/py/asmthumb.c b/py/asmthumb.c
index 749c1e405..7e92e4de4 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -52,7 +52,7 @@ void asm_thumb_end_pass(asm_thumb_t *as) {
#if defined(MCU_SERIES_F7)
if (as->base.pass == MP_ASM_PASS_EMIT) {
- // flush D-cache, so the code emited is stored in memory
+ // flush D-cache, so the code emitted is stored in memory
SCB_CleanDCache_by_Addr((uint32_t*)as->base.code_base, as->base.code_size);
// invalidate I-cache
SCB_InvalidateICache();
diff --git a/py/bc.c b/py/bc.c
index fc1794683..2e481bce7 100644
--- a/py/bc.c
+++ b/py/bc.c
@@ -64,6 +64,14 @@ mp_uint_t mp_decode_uint_value(const byte *ptr) {
return mp_decode_uint(&ptr);
}
+// This function is used to help reduce stack usage at the caller, for the case when
+// the caller doesn't need the actual value and just wants to skip over it.
+const byte *mp_decode_uint_skip(const byte *ptr) {
+ while ((*ptr++) & 0x80) {
+ }
+ return ptr;
+}
+
STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) {
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
// generic message, used also for other argument issues
@@ -115,7 +123,7 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw
// get params
size_t n_state = mp_decode_uint(&code_state->ip);
- mp_decode_uint(&code_state->ip); // skip n_exc_stack
+ code_state->ip = mp_decode_uint_skip(code_state->ip); // skip n_exc_stack
size_t scope_flags = *code_state->ip++;
size_t n_pos_args = *code_state->ip++;
size_t n_kwonly_args = *code_state->ip++;
diff --git a/py/bc.h b/py/bc.h
index e8d428612..88045dc55 100644
--- a/py/bc.h
+++ b/py/bc.h
@@ -92,6 +92,7 @@ typedef struct _mp_code_state_t {
mp_uint_t mp_decode_uint(const byte **ptr);
mp_uint_t mp_decode_uint_value(const byte *ptr);
+const byte *mp_decode_uint_skip(const byte *ptr);
mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc);
mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args);
diff --git a/py/builtinimport.c b/py/builtinimport.c
index d01ebbe73..6994fc48f 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -271,7 +271,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
if (level != 0) {
// What we want to do here is to take name of current module,
// chop <level> trailing components, and concatenate with passed-in
- // module name, thus resolving relative import name into absolue.
+ // module name, thus resolving relative import name into absolute.
// This even appears to be correct per
// http://legacy.python.org/dev/peps/pep-0328/#relative-imports-and-name
// "Relative imports use a module's __name__ attribute to determine that
@@ -441,7 +441,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
#if MICROPY_CPYTHON_COMPAT
// Store module as "__main__" in the dictionary of loaded modules (returned by sys.modules).
mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)), MP_OBJ_NEW_QSTR(MP_QSTR___main__), module_obj);
- // Store real name in "__main__" attribute. Choosen semi-randonly, to reuse existing qstr's.
+ // Store real name in "__main__" attribute. Chosen semi-randonly, to reuse existing qstr's.
mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___main__), MP_OBJ_NEW_QSTR(mod_name));
#endif
}
diff --git a/py/compile.c b/py/compile.c
index 8533e0528..3b6a264d6 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -939,7 +939,7 @@ STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
}
}
} else {
- // some arbitrary statment that we can't delete (eg del 1)
+ // some arbitrary statement that we can't delete (eg del 1)
goto cannot_delete;
}
@@ -1090,7 +1090,7 @@ STATIC void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) {
STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
mp_parse_node_t pn_import_source = pns->nodes[0];
- // extract the preceeding .'s (if any) for a relative import, to compute the import level
+ // extract the preceding .'s (if any) for a relative import, to compute the import level
uint import_level = 0;
do {
mp_parse_node_t pn_rel;
diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py
index 92a19c392..525dec197 100644
--- a/py/makeqstrdefs.py
+++ b/py/makeqstrdefs.py
@@ -5,8 +5,10 @@ qstr. Each qstr is transformed into a qstr definition of the form 'Q(...)'.
This script works with Python 2.6, 2.7, 3.3 and 3.4.
"""
+from __future__ import print_function
+
import re
-import argparse
+import sys
import os
# Blacklist of qstrings that are specially handled in further
@@ -84,18 +86,18 @@ def cat_together():
if __name__ == "__main__":
- parser = argparse.ArgumentParser(description='Generates qstr definitions from a specified source')
-
- parser.add_argument('command',
- help='Command (split/cat)')
- parser.add_argument('input_filename',
- help='Name of the input file (when not specified, the script reads standard input)')
- parser.add_argument('output_dir',
- help='Output directory to store individual qstr files')
- parser.add_argument('output_file',
- help='Name of the output file with collected qstrs')
-
- args = parser.parse_args()
+ if len(sys.argv) != 5:
+ print('usage: %s command input_filename output_dir output_file' % sys.argv[0])
+ sys.exit(2)
+
+ class Args:
+ pass
+ args = Args()
+ args.command = sys.argv[1]
+ args.input_filename = sys.argv[2]
+ args.output_dir = sys.argv[3]
+ args.output_file = sys.argv[4]
+
try:
os.makedirs(args.output_dir)
except OSError:
diff --git a/py/misc.h b/py/misc.h
index a84603ceb..c2b1b232b 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -198,7 +198,7 @@ int DEBUG_printf(const char *fmt, ...);
extern mp_uint_t mp_verbose_flag;
// This is useful for unicode handling. Some CPU archs has
-// special instructions for efficient implentation of this
+// special instructions for efficient implementation of this
// function (e.g. CLZ on ARM).
// NOTE: this function is unused at the moment
#ifndef count_lead_ones
diff --git a/py/mkenv.mk b/py/mkenv.mk
index eb1e44fef..b167b2533 100644
--- a/py/mkenv.mk
+++ b/py/mkenv.mk
@@ -32,7 +32,7 @@ ifeq ($(BUILD_VERBOSE),0)
$(info Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.)
endif
-# default settings; can be overriden in main Makefile
+# default settings; can be overridden in main Makefile
PY_SRC ?= $(TOP)/py
BUILD ?= build
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index 17bd30c52..fe8159953 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -259,6 +259,35 @@ STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
+#if MICROPY_PY_BUILTINS_INPUT
+
+#include "py/mphal.h"
+#include "lib/mp-readline/readline.h"
+
+// A port can define mp_hal_readline if they want to use a custom function here
+#ifndef mp_hal_readline
+#define mp_hal_readline readline
+#endif
+
+STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
+ if (n_args == 1) {
+ mp_obj_print(args[0], PRINT_STR);
+ }
+ vstr_t line;
+ vstr_init(&line, 16);
+ int ret = mp_hal_readline(&line, "");
+ if (ret == CHAR_CTRL_C) {
+ nlr_raise(mp_obj_new_exception(&mp_type_KeyboardInterrupt));
+ }
+ if (line.len == 0 && ret == CHAR_CTRL_D) {
+ nlr_raise(mp_obj_new_exception(&mp_type_EOFError));
+ }
+ return mp_obj_new_str_from_vstr(&mp_type_str, &line);
+}
+MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input);
+
+#endif
+
STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
return mp_getiter(o_in, NULL);
}
@@ -676,6 +705,9 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
#endif
{ MP_ROM_QSTR(MP_QSTR_hex), MP_ROM_PTR(&mp_builtin_hex_obj) },
{ MP_ROM_QSTR(MP_QSTR_id), MP_ROM_PTR(&mp_builtin_id_obj) },
+ #if MICROPY_PY_BUILTINS_INPUT
+ { MP_ROM_QSTR(MP_QSTR_input), MP_ROM_PTR(&mp_builtin_input_obj) },
+ #endif
{ MP_ROM_QSTR(MP_QSTR_isinstance), MP_ROM_PTR(&mp_builtin_isinstance_obj) },
{ MP_ROM_QSTR(MP_QSTR_issubclass), MP_ROM_PTR(&mp_builtin_issubclass_obj) },
{ MP_ROM_QSTR(MP_QSTR_iter), MP_ROM_PTR(&mp_builtin_iter_obj) },
diff --git a/py/modsys.c b/py/modsys.c
index 5fbcb944c..b8c427ba8 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -74,12 +74,12 @@ STATIC MP_DEFINE_ATTRTUPLE(
MP_ROM_PTR(&mp_sys_implementation_version_info_obj)
);
#else
-STATIC const mp_obj_tuple_t mp_sys_implementation_obj = {
+STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
{&mp_type_tuple},
2,
{
- MP_OBJ_NEW_QSTR(MP_QSTR_micropython),
- (mp_obj_t)&mp_sys_implementation_version_info_obj,
+ MP_ROM_QSTR(MP_QSTR_micropython),
+ MP_ROM_PTR(&mp_sys_implementation_version_info_obj),
}
};
#endif
diff --git a/py/mpconfig.h b/py/mpconfig.h
index a61d431e5..1ec8ae21c 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -32,7 +32,7 @@
// mpconfigport.h is a file containing configuration settings for a
// particular port. mpconfigport.h is actually a default name for
-// such config, and it can be overriden using MP_CONFIGFILE preprocessor
+// such config, and it can be overridden using MP_CONFIGFILE preprocessor
// define (you can do that by passing CFLAGS_EXTRA='-DMP_CONFIGFILE="<file.h>"'
// argument to make when using standard MicroPython makefiles).
// This is useful to have more than one config per port, for example,
@@ -791,6 +791,12 @@ typedef double mp_float_t;
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
#endif
+// Whether to provide the built-in input() function. The implementation of this
+// uses mp-readline, so can only be enabled if the port uses this readline.
+#ifndef MICROPY_PY_BUILTINS_INPUT
+#define MICROPY_PY_BUILTINS_INPUT (0)
+#endif
+
// Whether to support min/max functions
#ifndef MICROPY_PY_BUILTINS_MIN_MAX
#define MICROPY_PY_BUILTINS_MIN_MAX (1)
diff --git a/py/mperrno.h b/py/mperrno.h
index 4d092de45..6ea99ae22 100644
--- a/py/mperrno.h
+++ b/py/mperrno.h
@@ -73,6 +73,7 @@
#define MP_ECONNABORTED (103) // Software caused connection abort
#define MP_ECONNRESET (104) // Connection reset by peer
#define MP_ENOBUFS (105) // No buffer space available
+#define MP_EISCONN (106) // Transport endpoint is already connected
#define MP_ENOTCONN (107) // Transport endpoint is not connected
#define MP_ETIMEDOUT (110) // Connection timed out
#define MP_ECONNREFUSED (111) // Connection refused
@@ -127,6 +128,7 @@
#define MP_ECONNABORTED ECONNABORTED
#define MP_ECONNRESET ECONNRESET
#define MP_ENOBUFS ENOBUFS
+#define MP_EISCONN EISCONN
#define MP_ENOTCONN ENOTCONN
#define MP_ETIMEDOUT ETIMEDOUT
#define MP_ECONNREFUSED ECONNREFUSED
diff --git a/py/obj.c b/py/obj.c
index 98ffa930b..493945a22 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -401,7 +401,7 @@ mp_obj_t mp_obj_id(mp_obj_t o_in) {
return MP_OBJ_NEW_SMALL_INT(id);
} else {
// If that didn't work, well, let's return long int, just as
- // a (big) positve value, so it will never clash with the range
+ // a (big) positive value, so it will never clash with the range
// of small int returned in previous case.
return mp_obj_new_int_from_uint((mp_uint_t)id);
}
diff --git a/py/objfun.c b/py/objfun.c
index 08d031c8d..9f3589124 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -141,11 +141,11 @@ const mp_obj_type_t mp_type_fun_builtin_var = {
/* byte code functions */
qstr mp_obj_code_get_name(const byte *code_info) {
- mp_decode_uint(&code_info); // skip code_info_size entry
+ code_info = mp_decode_uint_skip(code_info); // skip code_info_size entry
#if MICROPY_PERSISTENT_CODE
return code_info[0] | (code_info[1] << 8);
#else
- return mp_decode_uint(&code_info);
+ return mp_decode_uint_value(code_info);
#endif
}
@@ -163,8 +163,8 @@ qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) {
#endif
const byte *bc = fun->bytecode;
- mp_decode_uint(&bc); // skip n_state
- mp_decode_uint(&bc); // skip n_exc_stack
+ bc = mp_decode_uint_skip(bc); // skip n_state
+ bc = mp_decode_uint_skip(bc); // skip n_exc_stack
bc++; // skip scope_params
bc++; // skip n_pos_args
bc++; // skip n_kwonly_args
@@ -205,12 +205,9 @@ mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args
MP_STACK_CHECK();
mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
- // get start of bytecode
- const byte *ip = self->bytecode;
-
// bytecode prelude: state size and exception stack size
- size_t n_state = mp_decode_uint(&ip);
- size_t n_exc_stack = mp_decode_uint(&ip);
+ size_t n_state = mp_decode_uint_value(self->bytecode);
+ size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode));
// allocate state for locals and stack
size_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t);
@@ -243,12 +240,9 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
DEBUG_printf("Func n_def_args: %d\n", self->n_def_args);
- // get start of bytecode
- const byte *ip = self->bytecode;
-
// bytecode prelude: state size and exception stack size
- size_t n_state = mp_decode_uint(&ip);
- size_t n_exc_stack = mp_decode_uint(&ip);
+ size_t n_state = mp_decode_uint_value(self->bytecode);
+ size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode));
#if VM_DETECT_STACK_OVERFLOW
n_state += 1;
diff --git a/py/objgenerator.c b/py/objgenerator.c
index 2e57fdf4b..8cb0e60cc 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -54,12 +54,9 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
mp_obj_fun_bc_t *self_fun = (mp_obj_fun_bc_t*)self->fun;
assert(self_fun->base.type == &mp_type_fun_bc);
- // get start of bytecode
- const byte *ip = self_fun->bytecode;
-
// bytecode prelude: get state size and exception stack size
- mp_uint_t n_state = mp_decode_uint(&ip);
- mp_uint_t n_exc_stack = mp_decode_uint(&ip);
+ size_t n_state = mp_decode_uint_value(self_fun->bytecode);
+ size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self_fun->bytecode));
// allocate the generator object, with room for local stack and exception stack
mp_obj_gen_instance_t *o = m_new_obj_var(mp_obj_gen_instance_t, byte,
diff --git a/py/objstr.c b/py/objstr.c
index 70de0a693..e758dd006 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -602,6 +602,11 @@ STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
GET_STR_DATA_LEN(args[0], s, len);
mp_int_t splits = mp_obj_get_int(args[2]);
+ if (splits < 0) {
+ // Negative limit means no limit, so delegate to split().
+ return mp_obj_str_split(n_args, args);
+ }
+
mp_int_t org_splits = splits;
// Preallocate list to the max expected # of elements, as we
// will fill it from the end.
@@ -798,7 +803,7 @@ STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
}
assert(last_good_char_pos >= first_good_char_pos);
- //+1 to accomodate the last character
+ //+1 to accommodate the last character
size_t stripped_len = last_good_char_pos - first_good_char_pos + 1;
if (stripped_len == orig_str_len) {
// If nothing was stripped, don't bother to dup original string
@@ -1811,7 +1816,7 @@ STATIC mp_obj_t str_islower(mp_obj_t self_in) {
}
#if MICROPY_CPYTHON_COMPAT
-// These methods are superfluous in the presense of str() and bytes()
+// These methods are superfluous in the presence of str() and bytes()
// constructors.
// TODO: should accept kwargs too
STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
@@ -2130,7 +2135,7 @@ typedef struct _mp_obj_str8_it_t {
#if !MICROPY_PY_BUILTINS_STR_UNICODE
STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
- mp_obj_str8_it_t *self = self_in;
+ mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in);
GET_STR_DATA_LEN(self->str, str, len);
if (self->cur < len) {
mp_obj_t o_out = mp_obj_new_str((const char*)str + self->cur, 1, true);
@@ -2148,7 +2153,7 @@ STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_bu
o->iternext = str_it_iternext;
o->str = str;
o->cur = 0;
- return o;
+ return MP_OBJ_FROM_PTR(o);
}
#endif
diff --git a/py/objstringio.c b/py/objstringio.c
index 9f4adeebb..645c441cb 100644
--- a/py/objstringio.c
+++ b/py/objstringio.c
@@ -68,10 +68,23 @@ STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *er
return size;
}
+STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) {
+ const void *buf = o->vstr->buf;
+ o->vstr->buf = m_new(char, o->vstr->len);
+ memcpy(o->vstr->buf, buf, o->vstr->len);
+ o->vstr->fixed_buf = false;
+ o->ref_obj = MP_OBJ_NULL;
+}
+
STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
(void)errcode;
mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
check_stringio_is_open(o);
+
+ if (o->vstr->fixed_buf) {
+ stringio_copy_on_write(o);
+ }
+
mp_uint_t new_pos = o->pos + size;
if (new_pos < size) {
// Writing <size> bytes will overflow o->pos beyond limit of mp_uint_t.
@@ -155,11 +168,11 @@ STATIC mp_obj_t stringio___exit__(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stringio___exit___obj, 4, 4, stringio___exit__);
-STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type, mp_uint_t alloc) {
+STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) {
mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t);
o->base.type = type;
- o->vstr = vstr_new(alloc);
o->pos = 0;
+ o->ref_obj = MP_OBJ_NULL;
return o;
}
@@ -170,17 +183,28 @@ STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, s
bool initdata = false;
mp_buffer_info_t bufinfo;
+ mp_obj_stringio_t *o = stringio_new(type_in);
+
if (n_args > 0) {
if (MP_OBJ_IS_INT(args[0])) {
sz = mp_obj_get_int(args[0]);
} else {
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ);
+
+ if (MP_OBJ_IS_STR_OR_BYTES(args[0])) {
+ o->vstr = m_new_obj(vstr_t);
+ vstr_init_fixed_buf(o->vstr, bufinfo.len, bufinfo.buf);
+ o->vstr->len = bufinfo.len;
+ o->ref_obj = args[0];
+ return MP_OBJ_FROM_PTR(o);
+ }
+
sz = bufinfo.len;
initdata = true;
}
}
- mp_obj_stringio_t *o = stringio_new(type_in, sz);
+ o->vstr = vstr_new(sz);
if (initdata) {
stringio_write(MP_OBJ_FROM_PTR(o), bufinfo.buf, bufinfo.len, NULL);
diff --git a/py/objstringio.h b/py/objstringio.h
index 853bfb11b..56738f4e4 100644
--- a/py/objstringio.h
+++ b/py/objstringio.h
@@ -33,6 +33,8 @@ typedef struct _mp_obj_stringio_t {
vstr_t *vstr;
// StringIO has single pointer used for both reading and writing
mp_uint_t pos;
+ // Underlying object buffered by this StringIO
+ mp_obj_t ref_obj;
} mp_obj_stringio_t;
#endif // MICROPY_INCLUDED_PY_OBJSTRINGIO_H
diff --git a/py/persistentcode.c b/py/persistentcode.c
index a71045a29..2fa8c1df0 100644
--- a/py/persistentcode.c
+++ b/py/persistentcode.c
@@ -286,11 +286,13 @@ STATIC void save_obj(mp_print_t *print, mp_obj_t o) {
byte obj_type;
if (MP_OBJ_IS_TYPE(o, &mp_type_int)) {
obj_type = 'i';
- } else if (mp_obj_is_float(o)) {
- obj_type = 'f';
- } else {
- assert(MP_OBJ_IS_TYPE(o, &mp_type_complex));
+ #if MICROPY_PY_BUILTINS_COMPLEX
+ } else if (MP_OBJ_IS_TYPE(o, &mp_type_complex)) {
obj_type = 'c';
+ #endif
+ } else {
+ assert(mp_obj_is_float(o));
+ obj_type = 'f';
}
vstr_t vstr;
mp_print_t pr;
diff --git a/py/py.mk b/py/py.mk
index 30109ac06..96fc92cac 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -25,7 +25,7 @@ ifeq ($(MICROPY_SSL_AXTLS),1)
CFLAGS_MOD += -DMICROPY_SSL_AXTLS=1 -I../lib/axtls/ssl -I../lib/axtls/crypto -I../lib/axtls/config
LDFLAGS_MOD += -Lbuild -laxtls
else ifeq ($(MICROPY_SSL_MBEDTLS),1)
-# Can be overriden by ports which have "builtin" mbedTLS
+# Can be overridden by ports which have "builtin" mbedTLS
MICROPY_SSL_MBEDTLS_INCLUDE ?= ../lib/mbedtls/include
CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(MICROPY_SSL_MBEDTLS_INCLUDE)
LDFLAGS_MOD += -L../lib/mbedtls/library -lmbedx509 -lmbedtls -lmbedcrypto
diff --git a/py/ringbuf.h b/py/ringbuf.h
index 5662594f7..5e108afad 100644
--- a/py/ringbuf.h
+++ b/py/ringbuf.h
@@ -33,7 +33,7 @@ typedef struct _ringbuf_t {
uint16_t iput;
} ringbuf_t;
-// Static initalization:
+// Static initialization:
// byte buf_array[N];
// ringbuf_t buf = {buf_array, sizeof(buf_array)};
diff --git a/py/stream.c b/py/stream.c
index c915110e0..d3fc767bb 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -51,7 +51,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in);
#define STREAM_CONTENT_TYPE(stream) (((stream)->is_text) ? &mp_type_str : &mp_type_bytes)
// Returns error condition in *errcode, if non-zero, return value is number of bytes written
-// before error condition occured. If *errcode == 0, returns total bytes written (which will
+// before error condition occurred. If *errcode == 0, returns total bytes written (which will
// be equal to input size).
mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode, byte flags) {
byte *buf = buf_;
diff --git a/py/vm.c b/py/vm.c
index 5094e3e45..404c79912 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -947,7 +947,7 @@ unwind_jump:;
DECODE_UINT;
// unum & 0xff == n_positional
// (unum >> 8) & 0xff == n_keyword
- // We have folowing stack layout here:
+ // We have following stack layout here:
// fun arg0 arg1 ... kw0 val0 kw1 val1 ... seq dict <- TOS
sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 2;
#if MICROPY_STACKLESS
@@ -1018,7 +1018,7 @@ unwind_jump:;
DECODE_UINT;
// unum & 0xff == n_positional
// (unum >> 8) & 0xff == n_keyword
- // We have folowing stack layout here:
+ // We have following stack layout here:
// fun self arg0 arg1 ... kw0 val0 kw1 val1 ... seq dict <- TOS
sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 3;
#if MICROPY_STACKLESS
@@ -1363,22 +1363,25 @@ unwind_loop:
// TODO need a better way of not adding traceback to constant objects (right now, just GeneratorExit_obj and MemoryError_obj)
if (nlr.ret_val != &mp_const_GeneratorExit_obj && nlr.ret_val != &mp_const_MemoryError_obj) {
const byte *ip = code_state->fun_bc->bytecode;
- mp_decode_uint(&ip); // skip n_state
- mp_decode_uint(&ip); // skip n_exc_stack
+ ip = mp_decode_uint_skip(ip); // skip n_state
+ ip = mp_decode_uint_skip(ip); // skip n_exc_stack
ip++; // skip scope_params
ip++; // skip n_pos_args
ip++; // skip n_kwonly_args
ip++; // skip n_def_pos_args
size_t bc = code_state->ip - ip;
- size_t code_info_size = mp_decode_uint(&ip);
+ size_t code_info_size = mp_decode_uint_value(ip);
+ ip = mp_decode_uint_skip(ip); // skip code_info_size
bc -= code_info_size;
#if MICROPY_PERSISTENT_CODE
qstr block_name = ip[0] | (ip[1] << 8);
qstr source_file = ip[2] | (ip[3] << 8);
ip += 4;
#else
- qstr block_name = mp_decode_uint(&ip);
- qstr source_file = mp_decode_uint(&ip);
+ qstr block_name = mp_decode_uint_value(ip);
+ ip = mp_decode_uint_skip(ip);
+ qstr source_file = mp_decode_uint_value(ip);
+ ip = mp_decode_uint_skip(ip);
#endif
size_t source_line = 1;
size_t c;
diff --git a/qemu-arm/Makefile b/qemu-arm/Makefile
index d4bbe8d58..07aa68572 100644
--- a/qemu-arm/Makefile
+++ b/qemu-arm/Makefile
@@ -34,15 +34,15 @@ endif
## - gcc-arm-none-eabi-4_8-2014q1/share/gcc-arm-none-eabi/samples/src/qemu/Makefile
LDFLAGS= --specs=nano.specs --specs=rdimon.specs -Wl,--gc-sections -Wl,-Map=$(@:.elf=.map)
-SRC_C = \
- main.c \
+SRC_COMMON_C = \
moduos.c \
modmachine.c \
+SRC_RUN_C = \
+ main.c \
+
SRC_TEST_C = \
test_main.c \
- moduos.c \
- modmachine.c \
LIB_SRC_C = $(addprefix lib/,\
libm/math.c \
@@ -69,25 +69,24 @@ STM_SRC_C = $(addprefix stmhal/,\
pybstdio.c \
)
-SRC_S = \
+OBJ_COMMON =
+OBJ_COMMON += $(PY_O)
+OBJ_COMMON += $(addprefix $(BUILD)/, $(SRC_COMMON_C:.c=.o))
+OBJ_COMMON += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
+OBJ_COMMON += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
-OBJ =
-OBJ += $(PY_O)
-OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
-OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
-OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
-OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
+OBJ_RUN =
+OBJ_RUN += $(addprefix $(BUILD)/, $(SRC_RUN_C:.c=.o))
OBJ_TEST =
-OBJ_TEST += $(PY_O)
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_TEST_C:.c=.o))
-OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
-OBJ_TEST += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
-OBJ_TEST += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
OBJ_TEST += $(BUILD)/tinytest.o
+# All object files, needed to get dependencies correct
+OBJ = $(OBJ_COMMON) $(OBJ_RUN) $(OBJ_TEST)
+
# List of sources for qstr extraction
-SRC_QSTR += $(SRC_C) $(STM_SRC_C)
+SRC_QSTR += $(SRC_COMMON_C) $(SRC_RUN_C) $(STM_SRC_C)
all: run
@@ -109,11 +108,11 @@ $(BUILD)/tinytest.o:
$(Q)$(CC) $(CFLAGS) -DNO_FORKING -o $@ -c ../tools/tinytest/tinytest.c
## `$(LD)` doesn't seem to like `--specs` for some reason, but we can just use `$(CC)` here.
-$(BUILD)/firmware.elf: $(OBJ)
+$(BUILD)/firmware.elf: $(OBJ_COMMON) $(OBJ_RUN)
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
$(Q)$(SIZE) $@
-$(BUILD)/firmware-test.elf: $(OBJ_TEST)
+$(BUILD)/firmware-test.elf: $(OBJ_COMMON) $(OBJ_TEST)
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
$(Q)$(SIZE) $@
diff --git a/qemu-arm/README.md b/qemu-arm/README.md
index 329ae4d92..0cf93c7d5 100644
--- a/qemu-arm/README.md
+++ b/qemu-arm/README.md
@@ -4,7 +4,7 @@ provided by QEMU (http://qemu.org).
The purposes of this port are to enable:
1. Continuous integration
- - run tests agains architecture-specific parts of code base
+ - run tests against architecture-specific parts of code base
2. Experimentation
- simulation & prototyping of anything that has architecture-specific
code
diff --git a/qemu-arm/mpconfigport.h b/qemu-arm/mpconfigport.h
index 974d3520b..ebec027e8 100644
--- a/qemu-arm/mpconfigport.h
+++ b/qemu-arm/mpconfigport.h
@@ -6,7 +6,8 @@
#define MICROPY_EMIT_X64 (0)
#define MICROPY_EMIT_THUMB (1)
#define MICROPY_EMIT_INLINE_THUMB (1)
-#define MICROPY_MEM_STATS (0)
+#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
+#define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTERS (0)
#define MICROPY_ENABLE_GC (1)
#define MICROPY_STACK_CHECK (1)
@@ -34,6 +35,7 @@
#define MICROPY_PY_UHEAPQ (1)
#define MICROPY_PY_UHASHLIB (1)
#define MICROPY_PY_MACHINE (1)
+#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
#define MICROPY_USE_INTERNAL_PRINTF (0)
#define MICROPY_VFS (1)
diff --git a/stmhal/Makefile b/stmhal/Makefile
index 09643be94..2d9d44afd 100644
--- a/stmhal/Makefile
+++ b/stmhal/Makefile
@@ -147,7 +147,6 @@ SRC_C = \
gccollect.c \
pybstdio.c \
help.c \
- input.c \
machine_i2c.c \
modmachine.c \
modpyb.c \
diff --git a/stmhal/adc.c b/stmhal/adc.c
index 9ab725fe2..6485e2ab7 100644
--- a/stmhal/adc.c
+++ b/stmhal/adc.c
@@ -93,7 +93,7 @@
#elif defined(STM32F427xx) || defined(STM32F429xx) || \
defined(STM32F437xx) || defined(STM32F439xx) || \
defined(STM32F746xx) || defined(STM32F767xx) || \
- defined(STM32F769xx)
+ defined(STM32F769xx) || defined(STM32F446xx)
#define VBAT_DIV (4)
#elif defined(STM32L476xx)
#define VBAT_DIV (3)
diff --git a/stmhal/boards/NUCLEO_F446RE/mpconfigboard.h b/stmhal/boards/NUCLEO_F446RE/mpconfigboard.h
new file mode 100644
index 000000000..d801fa188
--- /dev/null
+++ b/stmhal/boards/NUCLEO_F446RE/mpconfigboard.h
@@ -0,0 +1,64 @@
+#define MICROPY_HW_BOARD_NAME "NUCLEO-F446RE"
+#define MICROPY_HW_MCU_NAME "STM32F446xx"
+
+#define MICROPY_HW_HAS_SWITCH (1)
+#define MICROPY_HW_HAS_FLASH (1)
+#define MICROPY_HW_ENABLE_RTC (1)
+
+// HSE is 8MHz, CPU freq set to 168MHz. Using PLLQ for USB this gives a nice
+// 48 MHz clock for USB. To goto 180 MHz, I think that USB would need to be
+// configured to use PLLSAI
+#define MICROPY_HW_CLK_PLLM (8)
+#define MICROPY_HW_CLK_PLLN (336)
+#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2)
+#define MICROPY_HW_CLK_PLLQ (7)
+
+// UART config
+#define MICROPY_HW_UART2_TX (pin_A2)
+#define MICROPY_HW_UART2_RX (pin_A3)
+#define MICROPY_HW_UART6_TX (pin_C6)
+#define MICROPY_HW_UART6_RX (pin_C7)
+// UART 2 connects to the STM32F103 (STLINK) on the Nucleo board
+// and this is exposed as a USB Serial port.
+#define MICROPY_HW_UART_REPL PYB_UART_2
+#define MICROPY_HW_UART_REPL_BAUD 115200
+
+// I2C busses
+#define MICROPY_HW_I2C1_SCL (pin_B6) // Arduino D10, pin 17 on CN10
+#define MICROPY_HW_I2C1_SDA (pin_B7) // pin 21 on CN7
+#define MICROPY_HW_I2C2_SCL (pin_B10) // Arduino D6, pin 25 on CN10
+#define MICROPY_HW_I2C2_SDA (pin_B3) // Arduino D3, pin 31 on CN10
+#define MICROPY_HW_I2C3_SCL (pin_A8) // Arduino D7, pin 23 on CN10
+#define MICROPY_HW_I2C3_SDA (pin_C9) // pin 1 on CN10
+
+// SPI busses
+#define MICROPY_HW_SPI1_NSS (pin_A15) // pin 17 on CN7
+#define MICROPY_HW_SPI1_SCK (pin_A5) // Arduino D13, pin 11 on CN10
+#define MICROPY_HW_SPI1_MISO (pin_A6) // Arduino D12, pin 13 on CN10
+#define MICROPY_HW_SPI1_MOSI (pin_A7) // Arduino D11, pin 15 on CN10
+
+#define MICROPY_HW_SPI2_NSS (pin_B12) // pin 16 on CN10
+#define MICROPY_HW_SPI2_SCK (pin_B13) // pin 30 on CN10
+#define MICROPY_HW_SPI2_MISO (pin_B14) // pin 28 on CN10
+#define MICROPY_HW_SPI2_MOSI (pin_B15) // pin 26 on CN10
+
+#define MICROPY_HW_SPI3_NSS (pin_A4) // Arduino A2, pin 32 on CN7
+#define MICROPY_HW_SPI3_SCK (pin_B3) // Arduino D3, pin 31 on CN10
+#define MICROPY_HW_SPI3_MISO (pin_B4) // Arduino D5, pin 27 on CN10
+#define MICROPY_HW_SPI3_MOSI (pin_B5) // Arduino D4, pin 29 on CN10
+
+#define MICROPY_HW_SPI4_NSS (pin_B12) // pin 16 on CN10
+#define MICROPY_HW_SPI4_SCK (pin_B13) // pin 30 on CN10
+#define MICROPY_HW_SPI4_MISO (pin_A1) // pin 30 on CN7
+#define MICROPY_HW_SPI4_MOSI (pin_A11) // pin 14 on CN10
+
+// USRSW is pulled low. Pressing the button makes the input go high.
+#define MICROPY_HW_USRSW_PIN (pin_C13)
+#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
+#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
+#define MICROPY_HW_USRSW_PRESSED (0)
+
+// LEDs
+#define MICROPY_HW_LED1 (pin_A5) // Green LD2 LED on Nucleo
+#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
+#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
diff --git a/stmhal/boards/NUCLEO_F446RE/mpconfigboard.mk b/stmhal/boards/NUCLEO_F446RE/mpconfigboard.mk
new file mode 100644
index 000000000..e1ec6d57c
--- /dev/null
+++ b/stmhal/boards/NUCLEO_F446RE/mpconfigboard.mk
@@ -0,0 +1,4 @@
+MCU_SERIES = f4
+CMSIS_MCU = STM32F446xx
+AF_FILE = boards/stm32f429_af.csv
+LD_FILE = boards/stm32f411.ld
diff --git a/stmhal/boards/NUCLEO_F446RE/pins.csv b/stmhal/boards/NUCLEO_F446RE/pins.csv
new file mode 100644
index 000000000..5b09bcc74
--- /dev/null
+++ b/stmhal/boards/NUCLEO_F446RE/pins.csv
@@ -0,0 +1,72 @@
+D0,PA3
+D1,PA2
+D2,PA10
+D3,PB3
+D4,PB5
+D5,PB4
+D6,PB10
+D7,PA8
+D8,PA9
+D9,PC7
+D10,PB6
+D11,PA7
+D12,PA6
+D13,PA5
+D14,PB9
+D15,PB8
+A0,PA0
+A1,PA1
+A2,PA4
+A3,PB0
+A4,PC1
+A5,PC0
+PA0,PA0
+PA1,PA1
+PA2,PA2
+PA3,PA3
+PA4,PA4
+PA5,PA5
+PA6,PA6
+PA7,PA7
+PA8,PA8
+PA9,PA9
+PA10,PA10
+PA11,PA11
+PA12,PA12
+PA15,PA15
+PB0,PB0
+PB1,PB1
+PB2,PB2
+PB3,PB3
+PB4,PB4
+PB5,PB5
+PB6,PB6
+PB7,PB7
+PB8,PB8
+PB9,PB9
+PB10,PB10
+PB12,PB12
+PB13,PB13
+PB14,PB14
+PB15,PB15
+PC0,PC0
+PC1,PC1
+PC2,PC2
+PC3,PC3
+PC4,PC4
+PC5,PC5
+PC6,PC6
+PC7,PC7
+PC8,PC8
+PC9,PC9
+PC10,PC10
+PC11,PC11
+PC12,PC12
+PC13,PC13
+PC14,PC14
+PC15,PC15
+PD2,PD2
+PH0,PH0
+PH1,PH1
+LED,PA5
+SW,PC13
diff --git a/stmhal/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h b/stmhal/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h
new file mode 100644
index 000000000..3d0ce926b
--- /dev/null
+++ b/stmhal/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h
@@ -0,0 +1,413 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf.h
+ * @author MCD Application Team
+ * @version V1.1.0
+ * @date 19-June-2014
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+// This board doesn't really have USB, but the stmhal codebase doesn't build
+// without some USB defined, so we leave this on for now.
+#define USE_USB_FS
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+#define HAL_ADC_MODULE_ENABLED
+#define HAL_CAN_MODULE_ENABLED
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+#define HAL_DAC_MODULE_ENABLED
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_I2C_MODULE_ENABLED
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+#define HAL_RTC_MODULE_ENABLED
+/* #define HAL_SAI_MODULE_ENABLED */
+#define HAL_SD_MODULE_ENABLED
+#define HAL_SPI_MODULE_ENABLED
+#define HAL_TIM_MODULE_ENABLED
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+#define HAL_PCD_MODULE_ENABLED
+/* #define HAL_HCD_MODULE_ENABLED */
+
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)40000)
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0x00) /*!< tick interrupt priority */
+#define USE_RTOS 0
+#define PREFETCH_ENABLE 1
+#define INSTRUCTION_CACHE_ENABLE 1
+#define DATA_CACHE_ENABLE 1
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2
+#define MAC_ADDR1 0
+#define MAC_ADDR2 0
+#define MAC_ADDR3 0
+#define MAC_ADDR4 0
+#define MAC_ADDR5 0
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)4) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)4) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848 PHY Address*/
+#define DP83848_PHY_ADDRESS 0x01
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x000000FF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFF)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x10) /*!< PHY status register Offset */
+#define PHY_MICR ((uint16_t)0x11) /*!< MII Interrupt Control Register */
+#define PHY_MISR ((uint16_t)0x12) /*!< MII Interrupt Status and Misc. Control Register */
+
+#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/stmhal/boards/NUCLEO_F767ZI/mpconfigboard.h b/stmhal/boards/NUCLEO_F767ZI/mpconfigboard.h
index cafea136f..8952bce82 100644
--- a/stmhal/boards/NUCLEO_F767ZI/mpconfigboard.h
+++ b/stmhal/boards/NUCLEO_F767ZI/mpconfigboard.h
@@ -16,7 +16,7 @@
#define MICROPY_HW_ENABLE_RTC (1)
#define MICROPY_HW_ENABLE_TIMER (1)
#define MICROPY_HW_ENABLE_SERVO (0)
-#define MICROPY_HW_ENABLE_DAC (0)
+#define MICROPY_HW_ENABLE_DAC (1)
#define MICROPY_HW_ENABLE_CAN (1)
// HSE is 25MHz
diff --git a/stmhal/boards/NUCLEO_F767ZI/stm32f7xx_hal_conf.h b/stmhal/boards/NUCLEO_F767ZI/stm32f7xx_hal_conf.h
index d2c31cb09..e1aa4578d 100644
--- a/stmhal/boards/NUCLEO_F767ZI/stm32f7xx_hal_conf.h
+++ b/stmhal/boards/NUCLEO_F767ZI/stm32f7xx_hal_conf.h
@@ -58,7 +58,7 @@
/* #define HAL_CEC_MODULE_ENABLED */
/* #define HAL_CRC_MODULE_ENABLED */
/* #define HAL_CRYP_MODULE_ENABLED */
-/* #define HAL_DAC_MODULE_ENABLED */
+#define HAL_DAC_MODULE_ENABLED
/* #define HAL_DCMI_MODULE_ENABLED */
#define HAL_DMA_MODULE_ENABLED
/* #define HAL_DMA2D_MODULE_ENABLED */
diff --git a/stmhal/input.c b/stmhal/input.c
deleted file mode 100644
index c78525cc9..000000000
--- a/stmhal/input.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * This file is part of the Micro Python project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 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
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "py/nlr.h"
-#include "py/obj.h"
-#include "lib/mp-readline/readline.h"
-
-STATIC mp_obj_t mp_builtin_input(uint n_args, const mp_obj_t *args) {
- if (n_args == 1) {
- mp_obj_print(args[0], PRINT_STR);
- }
- vstr_t line;
- vstr_init(&line, 16);
- int ret = readline(&line, "");
- if (line.len == 0 && ret == CHAR_CTRL_D) {
- nlr_raise(mp_obj_new_exception(&mp_type_EOFError));
- }
- return mp_obj_new_str_from_vstr(&mp_type_str, &line);
-}
-
-MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input);
diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h
index 444ce9303..ac3c1f247 100644
--- a/stmhal/mpconfigport.h
+++ b/stmhal/mpconfigport.h
@@ -87,6 +87,7 @@
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
#define MICROPY_PY_BUILTINS_COMPILE (1)
#define MICROPY_PY_BUILTINS_EXECFILE (1)
+#define MICROPY_PY_BUILTINS_INPUT (1)
#define MICROPY_PY_BUILTINS_POW3 (1)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_TEXT stmhal_help_text
@@ -159,7 +160,6 @@
// extra built in names to add to the global namespace
#define MICROPY_PORT_BUILTINS \
- { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
// extra built in modules to add to the list of known ones
diff --git a/stmhal/storage.c b/stmhal/storage.c
index d0f278285..1931cd607 100644
--- a/stmhal/storage.c
+++ b/stmhal/storage.c
@@ -59,7 +59,7 @@
#define FLASH_MEM_SEG2_NUM_BLOCKS (128) // sector 11: 128k
#endif
-#elif defined(STM32F401xE) || defined(STM32F411xE)
+#elif defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
STATIC byte flash_cache_mem[0x4000] __attribute__((aligned(4))); // 16k
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
diff --git a/stmhal/usb.c b/stmhal/usb.c
index 9428cf7db..f70dea142 100644
--- a/stmhal/usb.c
+++ b/stmhal/usb.c
@@ -54,7 +54,7 @@
mp_uint_t pyb_usb_flags = 0;
#ifdef USE_DEVICE_MODE
-USBD_HandleTypeDef hUSBDDevice;
+STATIC USBD_HandleTypeDef hUSBDDevice;
pyb_usb_storage_medium_t pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_NONE;
#endif
@@ -568,7 +568,7 @@ STATIC mp_obj_t pyb_usb_hid_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_
mp_obj_t o_ret = pyb_buf_get_for_recv(vals[0].u_obj, &vstr);
// receive the data
- int ret = USBD_HID_Rx((uint8_t*)vstr.buf, vstr.len, vals[1].u_int);
+ int ret = USBD_HID_Rx(&hUSBDDevice, (uint8_t*)vstr.buf, vstr.len, vals[1].u_int);
// return the received data
if (o_ret != MP_OBJ_NULL) {
diff --git a/stmhal/usb.h b/stmhal/usb.h
index bc2b91c3d..42e6c76f8 100644
--- a/stmhal/usb.h
+++ b/stmhal/usb.h
@@ -47,7 +47,6 @@ typedef enum {
} USB_PHY_ID;
extern mp_uint_t pyb_usb_flags;
-extern struct _USBD_HandleTypeDef hUSBDDevice;
extern pyb_usb_storage_medium_t pyb_usb_storage_medium;
extern const struct _mp_obj_tuple_t pyb_usb_hid_mouse_obj;
extern const struct _mp_obj_tuple_t pyb_usb_hid_keyboard_obj;
diff --git a/stmhal/usbd_cdc_interface.c b/stmhal/usbd_cdc_interface.c
index 941025515..addcf8c85 100644
--- a/stmhal/usbd_cdc_interface.c
+++ b/stmhal/usbd_cdc_interface.c
@@ -82,10 +82,10 @@ static uint8_t UserTxBufPtrWaitCount = 0; // used to implement a timeout waiting
static uint8_t UserTxNeedEmptyPacket = 0; // used to flush the USB IN endpoint if the last packet was exactly the endpoint packet size
/* Private function prototypes -----------------------------------------------*/
-static int8_t CDC_Itf_Init (void);
+static int8_t CDC_Itf_Init (USBD_HandleTypeDef *pdev);
static int8_t CDC_Itf_DeInit (void);
static int8_t CDC_Itf_Control (uint8_t cmd, uint8_t* pbuf, uint16_t length);
-static int8_t CDC_Itf_Receive (uint8_t* pbuf, uint32_t *Len);
+static int8_t CDC_Itf_Receive (USBD_HandleTypeDef *pdev, uint8_t* pbuf, uint32_t *Len);
const USBD_CDC_ItfTypeDef USBD_CDC_fops = {
CDC_Itf_Init,
@@ -102,7 +102,7 @@ const USBD_CDC_ItfTypeDef USBD_CDC_fops = {
* @param None
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
*/
-static int8_t CDC_Itf_Init(void)
+static int8_t CDC_Itf_Init(USBD_HandleTypeDef *pdev)
{
#if 0
/*##-1- Configure the UART peripheral ######################################*/
@@ -141,8 +141,8 @@ static int8_t CDC_Itf_Init(void)
#endif
/*##-5- Set Application Buffers ############################################*/
- USBD_CDC_SetTxBuffer(&hUSBDDevice, UserTxBuffer, 0);
- USBD_CDC_SetRxBuffer(&hUSBDDevice, cdc_rx_packet_buf);
+ USBD_CDC_SetTxBuffer(pdev, UserTxBuffer, 0);
+ USBD_CDC_SetRxBuffer(pdev, cdc_rx_packet_buf);
cdc_rx_buf_put = 0;
cdc_rx_buf_get = 0;
@@ -288,9 +288,9 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
buffptr = UserTxBufPtrOutShadow;
- USBD_CDC_SetTxBuffer(&hUSBDDevice, (uint8_t*)&UserTxBuffer[buffptr], buffsize);
+ USBD_CDC_SetTxBuffer(hpcd->pData, (uint8_t*)&UserTxBuffer[buffptr], buffsize);
- if (USBD_CDC_TransmitPacket(&hUSBDDevice) == USBD_OK) {
+ if (USBD_CDC_TransmitPacket(hpcd->pData) == USBD_OK) {
UserTxBufPtrOutShadow += buffsize;
if (UserTxBufPtrOutShadow == APP_TX_DATA_SIZE) {
UserTxBufPtrOutShadow = 0;
@@ -317,7 +317,7 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
* @note The buffer we are passed here is just cdc_rx_packet_buf, so we are
* free to modify it.
*/
-static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
+static int8_t CDC_Itf_Receive(USBD_HandleTypeDef *pdev, uint8_t* Buf, uint32_t *Len) {
#if 0
// this sends the data over the UART using DMA
HAL_UART_Transmit_DMA(&UartHandle, Buf, *Len);
@@ -339,8 +339,8 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
}
// initiate next USB packet transfer
- USBD_CDC_SetRxBuffer(&hUSBDDevice, cdc_rx_packet_buf);
- USBD_CDC_ReceivePacket(&hUSBDDevice);
+ USBD_CDC_SetRxBuffer(pdev, cdc_rx_packet_buf);
+ USBD_CDC_ReceivePacket(pdev);
return USBD_OK;
}
diff --git a/stmhal/usbd_hid_interface.c b/stmhal/usbd_hid_interface.c
index 7a420c330..11b3a3acd 100644
--- a/stmhal/usbd_hid_interface.c
+++ b/stmhal/usbd_hid_interface.c
@@ -51,8 +51,8 @@ static uint32_t last_read_len = 0; // length of last read
static int8_t current_write_buffer = 0; // which buffer to write to
/* Private function prototypes -----------------------------------------------*/
-static int8_t HID_Itf_Init (void);
-static int8_t HID_Itf_Receive (uint8_t* pbuf, uint32_t Len);
+static int8_t HID_Itf_Init (USBD_HandleTypeDef *pdev);
+static int8_t HID_Itf_Receive (USBD_HandleTypeDef *pdev, uint8_t* pbuf, uint32_t Len);
const USBD_HID_ItfTypeDef USBD_HID_fops = {
HID_Itf_Init,
@@ -65,12 +65,12 @@ const USBD_HID_ItfTypeDef USBD_HID_fops = {
* @param None
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
*/
-static int8_t HID_Itf_Init(void)
+static int8_t HID_Itf_Init(USBD_HandleTypeDef *pdev)
{
current_read_buffer = 0;
last_read_len = 0;
current_write_buffer = 0;
- USBD_HID_SetRxBuffer(&hUSBDDevice, buffer[current_write_buffer]);
+ USBD_HID_SetRxBuffer(pdev, buffer[current_write_buffer]);
return USBD_OK;
}
@@ -83,14 +83,14 @@ static int8_t HID_Itf_Init(void)
* @note The buffer we are passed here is just UserRxBuffer, so we are
* free to modify it.
*/
-static int8_t HID_Itf_Receive(uint8_t* Buf, uint32_t Len) {
+static int8_t HID_Itf_Receive(USBD_HandleTypeDef *pdev, uint8_t* Buf, uint32_t Len) {
current_write_buffer = !current_write_buffer;
last_read_len = Len;
// initiate next USB packet transfer, to append to existing data in buffer
- USBD_HID_SetRxBuffer(&hUSBDDevice, buffer[current_write_buffer]);
- USBD_HID_ReceivePacket(&hUSBDDevice);
+ USBD_HID_SetRxBuffer(pdev, buffer[current_write_buffer]);
+ USBD_HID_ReceivePacket(pdev);
// Set NAK to indicate we need to process read buffer
- USBD_HID_SetNAK(&hUSBDDevice);
+ USBD_HID_SetNAK(pdev);
return USBD_OK;
}
@@ -101,7 +101,7 @@ int USBD_HID_RxNum(void) {
// timout in milliseconds.
// Returns number of bytes read from the device.
-int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout) {
+int USBD_HID_Rx(USBD_HandleTypeDef *pdev, uint8_t *buf, uint32_t len, uint32_t timeout) {
// Wait until we have buffer to read
uint32_t start = HAL_GetTick();
while (current_read_buffer == current_write_buffer) {
@@ -127,7 +127,7 @@ int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout) {
current_read_buffer = !current_read_buffer;
// Clear NAK to indicate we are ready to read more data
- USBD_HID_ClearNAK(&hUSBDDevice);
+ USBD_HID_ClearNAK(pdev);
// Success, return number of bytes read
return last_read_len;
diff --git a/stmhal/usbd_hid_interface.h b/stmhal/usbd_hid_interface.h
index 959c46ff8..fbc874796 100644
--- a/stmhal/usbd_hid_interface.h
+++ b/stmhal/usbd_hid_interface.h
@@ -7,4 +7,4 @@
extern const USBD_HID_ItfTypeDef USBD_HID_fops;
int USBD_HID_RxNum(void);
-int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout);
+int USBD_HID_Rx(USBD_HandleTypeDef *pdev, uint8_t *buf, uint32_t len, uint32_t timeout);
diff --git a/stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h b/stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h
index 5f0502766..96617b107 100644
--- a/stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h
+++ b/stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h
@@ -28,10 +28,10 @@ typedef struct {
} USBD_CDC_LineCodingTypeDef;
typedef struct _USBD_CDC_Itf {
- int8_t (* Init) (void);
+ int8_t (* Init) (USBD_HandleTypeDef *pdev);
int8_t (* DeInit) (void);
int8_t (* Control) (uint8_t, uint8_t * , uint16_t);
- int8_t (* Receive) (uint8_t *, uint32_t *);
+ int8_t (* Receive) (USBD_HandleTypeDef *pdev, uint8_t *, uint32_t *);
} USBD_CDC_ItfTypeDef;
typedef struct {
@@ -48,8 +48,8 @@ typedef struct {
} USBD_CDC_HandleTypeDef;
typedef struct _USBD_HID_Itf {
- int8_t (* Init) (void);
- int8_t (* Receive)(uint8_t *, uint32_t);
+ int8_t (* Init) (USBD_HandleTypeDef *pdev);
+ int8_t (* Receive)(USBD_HandleTypeDef *pdev, uint8_t *, uint32_t);
} USBD_HID_ItfTypeDef;
typedef struct _USBD_STORAGE {
diff --git a/stmhal/usbdev/class/inc/usbd_msc_scsi.h b/stmhal/usbdev/class/inc/usbd_msc_scsi.h
index dea247bca..34f059ee5 100644
--- a/stmhal/usbdev/class/inc/usbd_msc_scsi.h
+++ b/stmhal/usbdev/class/inc/usbd_msc_scsi.h
@@ -55,6 +55,8 @@
#define SCSI_MODE_SENSE6 0x1A
#define SCSI_MODE_SENSE10 0x5A
#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1E
+#define SCSI_SYNCHRONIZE_CACHE10 0x35
+#define SCSI_SYNCHRONIZE_CACHE16 0x91
#define SCSI_READ6 0x08
#define SCSI_READ10 0x28
#define SCSI_READ12 0xA8
diff --git a/stmhal/usbdev/class/src/usbd_cdc_msc_hid.c b/stmhal/usbdev/class/src/usbd_cdc_msc_hid.c
index cfae7224d..e0edf1370 100644
--- a/stmhal/usbdev/class/src/usbd_cdc_msc_hid.c
+++ b/stmhal/usbdev/class/src/usbd_cdc_msc_hid.c
@@ -669,7 +669,7 @@ static uint8_t USBD_CDC_MSC_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) {
CDC_CMD_PACKET_SIZE);
// Init physical Interface components
- CDC_fops->Init();
+ CDC_fops->Init(pdev);
// Init Xfer states
CDC_ClassData.TxState =0;
@@ -724,7 +724,7 @@ static uint8_t USBD_CDC_MSC_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) {
USBD_EP_TYPE_INTR,
mps_out);
- HID_fops->Init();
+ HID_fops->Init(pdev);
// Prepare Out endpoint to receive next packet
USBD_LL_PrepareReceive(pdev, hid_out_ep, HID_ClassData.RxBuffer, mps_out);
@@ -963,7 +963,7 @@ static uint8_t USBD_CDC_MSC_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
/* USB data will be immediately processed, this allow next USB traffic being
NAKed till the end of the application Xfer */
- CDC_fops->Receive(CDC_ClassData.RxBuffer, &CDC_ClassData.RxLength);
+ CDC_fops->Receive(pdev, CDC_ClassData.RxBuffer, &CDC_ClassData.RxLength);
return USBD_OK;
} else if ((usbd_mode & USBD_MODE_MSC) && epnum == (MSC_OUT_EP & 0x7f)) {
@@ -971,7 +971,7 @@ static uint8_t USBD_CDC_MSC_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
return USBD_OK;
} else if ((usbd_mode & USBD_MODE_HID) && epnum == (hid_out_ep & 0x7f)) {
HID_ClassData.RxLength = USBD_LL_GetRxDataSize(pdev, epnum);
- HID_fops->Receive(HID_ClassData.RxBuffer, HID_ClassData.RxLength);
+ HID_fops->Receive(pdev, HID_ClassData.RxBuffer, HID_ClassData.RxLength);
}
return USBD_OK;
diff --git a/stmhal/usbdev/class/src/usbd_msc_scsi.c b/stmhal/usbdev/class/src/usbd_msc_scsi.c
index 366f1f00e..b2931b745 100644
--- a/stmhal/usbdev/class/src/usbd_msc_scsi.c
+++ b/stmhal/usbdev/class/src/usbd_msc_scsi.c
@@ -89,6 +89,7 @@ static int8_t SCSI_StartStopUnit(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
static int8_t SCSI_AllowMediumRemoval(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
+static int8_t SCSI_SynchronizeCache(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
static int8_t SCSI_Write10(USBD_HandleTypeDef *pdev, uint8_t lun , uint8_t *params);
static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun , uint8_t *params);
static int8_t SCSI_Verify10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
@@ -151,6 +152,10 @@ int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev,
case SCSI_MODE_SENSE10:
return SCSI_ModeSense10 (pdev, lun, params);
+ case SCSI_SYNCHRONIZE_CACHE10:
+ case SCSI_SYNCHRONIZE_CACHE16:
+ return SCSI_SynchronizeCache(pdev, lun, params);
+
case SCSI_READ_FORMAT_CAPACITIES:
return SCSI_ReadFormatCapacity(pdev, lun, params);
@@ -374,6 +379,13 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
return 0;
}
+static int8_t SCSI_SynchronizeCache(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params) {
+ // nothing to synchronize, so just return "success"
+ USBD_MSC_BOT_HandleTypeDef *hmsc = pdev->pClassData;
+ hmsc->bot_data_length = 0;
+ return 0;
+}
+
/**
* @brief SCSI_RequestSense
* Process Request Sense command
diff --git a/teensy/Makefile b/teensy/Makefile
index 9f52cc3c7..923ea77ec 100644
--- a/teensy/Makefile
+++ b/teensy/Makefile
@@ -93,7 +93,6 @@ SRC_C = \
STM_SRC_C = $(addprefix stmhal/,\
gccollect.c \
- input.c \
irq.c \
pin.c \
pin_named_pins.c \
diff --git a/teensy/mpconfigport.h b/teensy/mpconfigport.h
index 8c4022046..de30924d9 100644
--- a/teensy/mpconfigport.h
+++ b/teensy/mpconfigport.h
@@ -14,6 +14,7 @@
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_OPT_COMPUTED_GOTO (1)
+#define MICROPY_PY_BUILTINS_INPUT (1)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_TEXT teensy_help_text
@@ -31,7 +32,6 @@
// extra built in names to add to the global namespace
#define MICROPY_PORT_BUILTINS \
- { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
// extra built in modules to add to the list of known ones
extern const struct _mp_obj_module_t os_module;
diff --git a/tests/basics/array1.py b/tests/basics/array1.py
index 43f775b79..bad879035 100644
--- a/tests/basics/array1.py
+++ b/tests/basics/array1.py
@@ -1,9 +1,8 @@
try:
import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
a = array.array('B', [1, 2, 3])
print(a, len(a))
diff --git a/tests/basics/array_add.py b/tests/basics/array_add.py
index 41cd77b42..76ce59f76 100644
--- a/tests/basics/array_add.py
+++ b/tests/basics/array_add.py
@@ -2,9 +2,8 @@
try:
import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
a1 = array.array('I', [1])
a2 = array.array('I', [2])
diff --git a/tests/basics/array_construct.py b/tests/basics/array_construct.py
index cafa57784..2221de990 100644
--- a/tests/basics/array_construct.py
+++ b/tests/basics/array_construct.py
@@ -3,9 +3,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# tuple, list
print(array('b', (1, 2)))
diff --git a/tests/basics/array_construct2.py b/tests/basics/array_construct2.py
index d1c1a6c70..c305b7f01 100644
--- a/tests/basics/array_construct2.py
+++ b/tests/basics/array_construct2.py
@@ -1,9 +1,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# construct from something with unknown length (requires generators)
print(array('i', (i for i in range(10))))
diff --git a/tests/basics/array_construct_endian.py b/tests/basics/array_construct_endian.py
index bf34b05d1..990d7b1ea 100644
--- a/tests/basics/array_construct_endian.py
+++ b/tests/basics/array_construct_endian.py
@@ -3,9 +3,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# raw copy from bytes, bytearray
print(array('h', b'12'))
diff --git a/tests/basics/array_intbig.py b/tests/basics/array_intbig.py
index 4a3b2a0d4..5702a8ae6 100644
--- a/tests/basics/array_intbig.py
+++ b/tests/basics/array_intbig.py
@@ -3,9 +3,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(array('L', [0, 2**32-1]))
print(array('l', [-2**31, 0, 2**31-1]))
diff --git a/tests/basics/array_micropython.py b/tests/basics/array_micropython.py
index 0c1df0923..e26ad7ae9 100644
--- a/tests/basics/array_micropython.py
+++ b/tests/basics/array_micropython.py
@@ -2,9 +2,8 @@
try:
import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# arrays of objects
a = array.array('O')
diff --git a/tests/basics/attrtuple1.py b/tests/basics/attrtuple1.py
index 597bfc2a3..78a0fbed1 100644
--- a/tests/basics/attrtuple1.py
+++ b/tests/basics/attrtuple1.py
@@ -8,9 +8,8 @@ t = sys.implementation
try:
t.name
except AttributeError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# test printing of attrtuple
diff --git a/tests/basics/builtin_delattr.py b/tests/basics/builtin_delattr.py
index 9b38837e4..65bd0f210 100644
--- a/tests/basics/builtin_delattr.py
+++ b/tests/basics/builtin_delattr.py
@@ -2,9 +2,8 @@
try:
delattr
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
class A: pass
a = A()
diff --git a/tests/basics/builtin_help.py b/tests/basics/builtin_help.py
index d554f308d..6ec39653f 100644
--- a/tests/basics/builtin_help.py
+++ b/tests/basics/builtin_help.py
@@ -4,8 +4,7 @@ try:
help
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
help() # no args
help(help) # help for a function
diff --git a/tests/basics/builtin_minmax.py b/tests/basics/builtin_minmax.py
index a925b3fe9..184398e64 100644
--- a/tests/basics/builtin_minmax.py
+++ b/tests/basics/builtin_minmax.py
@@ -3,9 +3,8 @@ try:
min
max
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(min(0,1))
print(min(1,0))
diff --git a/tests/basics/builtin_override.py b/tests/basics/builtin_override.py
index f3632e59a..9f91341ed 100644
--- a/tests/basics/builtin_override.py
+++ b/tests/basics/builtin_override.py
@@ -6,9 +6,8 @@ import builtins
try:
builtins.abs = lambda x: x + 1
except AttributeError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(abs(1))
diff --git a/tests/basics/builtin_pow3.py b/tests/basics/builtin_pow3.py
index dec7253bb..69b57e548 100644
--- a/tests/basics/builtin_pow3.py
+++ b/tests/basics/builtin_pow3.py
@@ -4,9 +4,8 @@
try:
print(pow(3, 4, 7))
except NotImplementedError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# 3 arg pow is defined to only work on integers
try:
diff --git a/tests/basics/builtin_pow3_intbig.py b/tests/basics/builtin_pow3_intbig.py
index 9f482cbde..bedc8b36b 100644
--- a/tests/basics/builtin_pow3_intbig.py
+++ b/tests/basics/builtin_pow3_intbig.py
@@ -4,9 +4,8 @@
try:
print(pow(3, 4, 7))
except NotImplementedError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(pow(555557, 1000002, 1000003))
diff --git a/tests/basics/builtin_property.py b/tests/basics/builtin_property.py
index ff4ff073c..89c3d4936 100644
--- a/tests/basics/builtin_property.py
+++ b/tests/basics/builtin_property.py
@@ -2,9 +2,8 @@
try:
property
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# create a property object explicitly
property()
diff --git a/tests/basics/builtin_range_attrs.py b/tests/basics/builtin_range_attrs.py
index 9327c802a..05d666d13 100644
--- a/tests/basics/builtin_range_attrs.py
+++ b/tests/basics/builtin_range_attrs.py
@@ -3,9 +3,8 @@
try:
range(0).start
except AttributeError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# attrs
print(range(1, 2, 3).start)
diff --git a/tests/basics/builtin_reversed.py b/tests/basics/builtin_reversed.py
index 59e9c7821..f43505a8b 100644
--- a/tests/basics/builtin_reversed.py
+++ b/tests/basics/builtin_reversed.py
@@ -2,9 +2,8 @@
try:
reversed
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# list
print(list(reversed([])))
diff --git a/tests/basics/builtin_sorted.py b/tests/basics/builtin_sorted.py
index 68855b61b..6435f86d0 100644
--- a/tests/basics/builtin_sorted.py
+++ b/tests/basics/builtin_sorted.py
@@ -3,9 +3,8 @@ try:
sorted
set
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(sorted(set(range(100))))
print(sorted(set(range(100)), key=lambda x: x + 100*(x % 2)))
diff --git a/tests/basics/bytearray_construct_array.py b/tests/basics/bytearray_construct_array.py
index 6d45cafda..bde5fa08b 100644
--- a/tests/basics/bytearray_construct_array.py
+++ b/tests/basics/bytearray_construct_array.py
@@ -2,9 +2,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# arrays
print(bytearray(array('b', [1, 2])))
diff --git a/tests/basics/bytearray_construct_endian.py b/tests/basics/bytearray_construct_endian.py
index f68f9b89d..0002f19c5 100644
--- a/tests/basics/bytearray_construct_endian.py
+++ b/tests/basics/bytearray_construct_endian.py
@@ -2,9 +2,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# arrays
print(bytearray(array('h', [1, 2])))
diff --git a/tests/basics/bytearray_slice_assign.py b/tests/basics/bytearray_slice_assign.py
index c4b5c43e3..48f5938a5 100644
--- a/tests/basics/bytearray_slice_assign.py
+++ b/tests/basics/bytearray_slice_assign.py
@@ -2,8 +2,7 @@ try:
bytearray()[:] = bytearray()
except TypeError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
# test slices; only 2 argument version supported by Micro Python at the moment
x = bytearray(range(10))
diff --git a/tests/basics/bytes_add_array.py b/tests/basics/bytes_add_array.py
index 2b8cbccef..b17556d83 100644
--- a/tests/basics/bytes_add_array.py
+++ b/tests/basics/bytes_add_array.py
@@ -2,9 +2,8 @@
try:
import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# should be byteorder-neutral
print(b"123" + array.array('h', [0x1515]))
diff --git a/tests/basics/bytes_add_endian.py b/tests/basics/bytes_add_endian.py
index 1bbd0f2c3..8cfffa7b6 100644
--- a/tests/basics/bytes_add_endian.py
+++ b/tests/basics/bytes_add_endian.py
@@ -2,8 +2,7 @@
try:
import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(b"123" + array.array('i', [1]))
diff --git a/tests/basics/bytes_compare_array.py b/tests/basics/bytes_compare_array.py
index ad41d1d37..ad378de70 100644
--- a/tests/basics/bytes_compare_array.py
+++ b/tests/basics/bytes_compare_array.py
@@ -1,9 +1,8 @@
try:
import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(array.array('b', [1, 2]) in b'\x01\x02\x03')
# CPython gives False here
diff --git a/tests/basics/bytes_construct_array.py b/tests/basics/bytes_construct_array.py
index 72c2d0c58..453eb5901 100644
--- a/tests/basics/bytes_construct_array.py
+++ b/tests/basics/bytes_construct_array.py
@@ -2,9 +2,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# arrays
print(bytes(array('b', [1, 2])))
diff --git a/tests/basics/bytes_construct_endian.py b/tests/basics/bytes_construct_endian.py
index 77e0eaaa5..cf1a9f408 100644
--- a/tests/basics/bytes_construct_endian.py
+++ b/tests/basics/bytes_construct_endian.py
@@ -3,9 +3,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# arrays
print(bytes(array('h', [1, 2])))
diff --git a/tests/basics/bytes_partition.py b/tests/basics/bytes_partition.py
index 7d3ffaaaa..5b503f544 100644
--- a/tests/basics/bytes_partition.py
+++ b/tests/basics/bytes_partition.py
@@ -2,8 +2,7 @@ try:
str.partition
except AttributeError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
print(b"asdf".partition(b'g'))
print(b"asdf".partition(b'a'))
diff --git a/tests/basics/class_delattr_setattr.py b/tests/basics/class_delattr_setattr.py
index 0d061aee6..190b4875b 100644
--- a/tests/basics/class_delattr_setattr.py
+++ b/tests/basics/class_delattr_setattr.py
@@ -6,9 +6,8 @@ try:
def __delattr__(self, attr): pass
del Test().noexist
except AttributeError:
- import sys
print('SKIP')
- sys.exit()
+ raise SystemExit
# this class just prints the calls to see if they were executed
class A():
diff --git a/tests/basics/class_descriptor.py b/tests/basics/class_descriptor.py
index 7f295f071..eb88ba7b9 100644
--- a/tests/basics/class_descriptor.py
+++ b/tests/basics/class_descriptor.py
@@ -21,9 +21,8 @@ m = Main()
try:
m.__class__
except AttributeError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
r = m.Forward
if 'Descriptor' in repr(r.__class__):
diff --git a/tests/basics/class_new.py b/tests/basics/class_new.py
index 0198456b2..9a7072ad0 100644
--- a/tests/basics/class_new.py
+++ b/tests/basics/class_new.py
@@ -3,9 +3,8 @@ try:
# nothing to test.
object.__new__
except AttributeError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
class A:
def __new__(cls):
print("A.__new__")
diff --git a/tests/basics/class_store_class.py b/tests/basics/class_store_class.py
index 00a291586..797f88f85 100644
--- a/tests/basics/class_store_class.py
+++ b/tests/basics/class_store_class.py
@@ -8,9 +8,8 @@ except ImportError:
try:
from ucollections import namedtuple
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
_DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ])
diff --git a/tests/basics/class_super_object.py b/tests/basics/class_super_object.py
index a841d34ab..1fddbb38f 100644
--- a/tests/basics/class_super_object.py
+++ b/tests/basics/class_super_object.py
@@ -4,9 +4,8 @@ try:
# nothing to test.
object.__init__
except AttributeError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
class Test(object):
def __init__(self):
diff --git a/tests/basics/dict_fromkeys2.py b/tests/basics/dict_fromkeys2.py
index 7ea0cc5b3..dce1e8ef5 100644
--- a/tests/basics/dict_fromkeys2.py
+++ b/tests/basics/dict_fromkeys2.py
@@ -1,9 +1,8 @@
try:
reversed
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# argument to fromkeys has no __len__
d = dict.fromkeys(reversed(range(1)))
diff --git a/tests/basics/enumerate.py b/tests/basics/enumerate.py
index 3cc1350a0..4f8239bf7 100644
--- a/tests/basics/enumerate.py
+++ b/tests/basics/enumerate.py
@@ -1,9 +1,8 @@
try:
enumerate
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(list(enumerate([])))
print(list(enumerate([1, 2, 3])))
diff --git a/tests/basics/errno1.py b/tests/basics/errno1.py
index eae1bbe1b..63930b767 100644
--- a/tests/basics/errno1.py
+++ b/tests/basics/errno1.py
@@ -4,8 +4,7 @@ try:
import uerrno
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
# check that constants exist and are integers
print(type(uerrno.EIO))
diff --git a/tests/basics/filter.py b/tests/basics/filter.py
index d0b36733c..c6d97cf9b 100644
--- a/tests/basics/filter.py
+++ b/tests/basics/filter.py
@@ -1,9 +1,8 @@
try:
filter
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(list(filter(lambda x: x & 1, range(-3, 4))))
print(list(filter(None, range(-3, 4))))
diff --git a/tests/basics/frozenset1.py b/tests/basics/frozenset1.py
index 7a4a33540..7bec24c29 100644
--- a/tests/basics/frozenset1.py
+++ b/tests/basics/frozenset1.py
@@ -4,8 +4,7 @@ try:
frozenset
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
s = frozenset()
print(s)
diff --git a/tests/basics/frozenset_add.py b/tests/basics/frozenset_add.py
index 415a8c2e1..fe24fbaf1 100644
--- a/tests/basics/frozenset_add.py
+++ b/tests/basics/frozenset_add.py
@@ -2,8 +2,7 @@ try:
frozenset
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
s = frozenset({1, 2, 3, 4})
try:
diff --git a/tests/basics/frozenset_binop.py b/tests/basics/frozenset_binop.py
index 5cc07e9e1..61af07a23 100644
--- a/tests/basics/frozenset_binop.py
+++ b/tests/basics/frozenset_binop.py
@@ -2,8 +2,7 @@ try:
frozenset
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
sets = [
frozenset(), frozenset({1}), frozenset({1, 2}), frozenset({1, 2, 3}), frozenset({2, 3}),
diff --git a/tests/basics/frozenset_copy.py b/tests/basics/frozenset_copy.py
index 92e115d34..c90f541a1 100644
--- a/tests/basics/frozenset_copy.py
+++ b/tests/basics/frozenset_copy.py
@@ -2,8 +2,7 @@ try:
frozenset
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
s = frozenset({1, 2, 3, 4})
t = s.copy()
diff --git a/tests/basics/frozenset_difference.py b/tests/basics/frozenset_difference.py
index 3d142f959..bc8b9c21c 100644
--- a/tests/basics/frozenset_difference.py
+++ b/tests/basics/frozenset_difference.py
@@ -2,8 +2,7 @@ try:
frozenset
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
l = [1, 2, 3, 4]
s = frozenset(l)
diff --git a/tests/basics/frozenset_set.py b/tests/basics/frozenset_set.py
index b334694b5..3bf456acf 100644
--- a/tests/basics/frozenset_set.py
+++ b/tests/basics/frozenset_set.py
@@ -2,8 +2,7 @@ try:
frozenset
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
# Examples from https://docs.python.org/3/library/stdtypes.html#set
# "Instances of set are compared to instances of frozenset based on their
diff --git a/tests/basics/fun_error2.py b/tests/basics/fun_error2.py
index c4d2c0b64..2a00396e6 100644
--- a/tests/basics/fun_error2.py
+++ b/tests/basics/fun_error2.py
@@ -3,8 +3,7 @@ try:
enumerate
except:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
def test_exc(code, exc):
try:
diff --git a/tests/basics/gc1.py b/tests/basics/gc1.py
index be6c6faed..dcbe0bfcf 100644
--- a/tests/basics/gc1.py
+++ b/tests/basics/gc1.py
@@ -4,8 +4,7 @@ try:
import gc
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
print(gc.isenabled())
gc.disable()
diff --git a/tests/basics/memoryview1.py b/tests/basics/memoryview1.py
index a771acdda..c4cc6ffab 100644
--- a/tests/basics/memoryview1.py
+++ b/tests/basics/memoryview1.py
@@ -2,9 +2,8 @@
try:
memoryview
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# test reading from bytes
b = b'1234'
diff --git a/tests/basics/memoryview2.py b/tests/basics/memoryview2.py
index 4b5af852b..06a7be59f 100644
--- a/tests/basics/memoryview2.py
+++ b/tests/basics/memoryview2.py
@@ -3,9 +3,8 @@ try:
from array import array
memoryview
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(list(memoryview(b'\x7f\x80\x81\xff')))
print(list(memoryview(array('b', [0x7f, -0x80]))))
diff --git a/tests/basics/memoryview_gc.py b/tests/basics/memoryview_gc.py
index 9d4857e36..d366cbbb1 100644
--- a/tests/basics/memoryview_gc.py
+++ b/tests/basics/memoryview_gc.py
@@ -2,9 +2,8 @@
try:
memoryview
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
b = bytearray(10)
m = memoryview(b)[1:]
diff --git a/tests/basics/memoryview_intbig.py b/tests/basics/memoryview_intbig.py
index 180f15d18..a76d9cbec 100644
--- a/tests/basics/memoryview_intbig.py
+++ b/tests/basics/memoryview_intbig.py
@@ -3,9 +3,8 @@ try:
from array import array
memoryview
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(list(memoryview(array('i', [0x7f000000, -0x80000000]))))
print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff]))))
diff --git a/tests/basics/namedtuple1.py b/tests/basics/namedtuple1.py
index 132dcf96b..b9a007240 100644
--- a/tests/basics/namedtuple1.py
+++ b/tests/basics/namedtuple1.py
@@ -4,9 +4,8 @@ try:
except ImportError:
from ucollections import namedtuple
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
T = namedtuple("Tup", ["foo", "bar"])
# CPython prints fully qualified name, what we don't bother to do so far
@@ -76,7 +75,7 @@ T4 = namedtuple("TupTuple", ("foo", "bar"))
t = T4(1, 2)
print(t.foo, t.bar)
-# Try single string with comma field seperator
+# Try single string with comma field separator
# Not implemented so far
#T2 = namedtuple("TupComma", "foo,bar")
#t = T2(1, 2)
diff --git a/tests/basics/object_dict.py b/tests/basics/object_dict.py
index e6fb7b3d9..7bf7094e3 100644
--- a/tests/basics/object_dict.py
+++ b/tests/basics/object_dict.py
@@ -1,4 +1,3 @@
-import sys
class Foo:
@@ -9,6 +8,6 @@ class Foo:
o = Foo()
if not hasattr(o, "__dict__"):
print("SKIP")
- sys.exit()
+ raise SystemExit
print(o.__dict__ == {'a': 1, 'b': 'bar'})
diff --git a/tests/basics/object_new.py b/tests/basics/object_new.py
index 568feccda..a9c9482cb 100644
--- a/tests/basics/object_new.py
+++ b/tests/basics/object_new.py
@@ -7,9 +7,8 @@ try:
# nothing to test.
object.__new__
except AttributeError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
class Foo:
diff --git a/tests/basics/op_error_memoryview.py b/tests/basics/op_error_memoryview.py
index 658ededc8..8d4403f77 100644
--- a/tests/basics/op_error_memoryview.py
+++ b/tests/basics/op_error_memoryview.py
@@ -2,9 +2,8 @@
try:
memoryview
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
def test_exc(code, exc):
try:
diff --git a/tests/basics/ordereddict1.py b/tests/basics/ordereddict1.py
index 7147968c5..d1633f0bb 100644
--- a/tests/basics/ordereddict1.py
+++ b/tests/basics/ordereddict1.py
@@ -5,8 +5,7 @@ except ImportError:
from ucollections import OrderedDict
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
d = OrderedDict([(10, 20), ("b", 100), (1, 2)])
print(len(d))
diff --git a/tests/basics/ordereddict_eq.py b/tests/basics/ordereddict_eq.py
index 274660877..c69daf880 100644
--- a/tests/basics/ordereddict_eq.py
+++ b/tests/basics/ordereddict_eq.py
@@ -5,8 +5,7 @@ except ImportError:
from ucollections import OrderedDict
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
x = OrderedDict()
y = OrderedDict()
diff --git a/tests/basics/parser.py b/tests/basics/parser.py
index 8fb2a49bf..626b67ad7 100644
--- a/tests/basics/parser.py
+++ b/tests/basics/parser.py
@@ -4,8 +4,7 @@ try:
compile
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
# completely empty string
# uPy and CPy differ for this case
diff --git a/tests/basics/set_type.py b/tests/basics/set_type.py
index d790fa062..787a99e81 100644
--- a/tests/basics/set_type.py
+++ b/tests/basics/set_type.py
@@ -5,9 +5,8 @@
try:
set
except NameError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(set)
diff --git a/tests/basics/slice_attrs.py b/tests/basics/slice_attrs.py
index 67456ff8e..e85ead4ba 100644
--- a/tests/basics/slice_attrs.py
+++ b/tests/basics/slice_attrs.py
@@ -8,9 +8,8 @@ class A:
try:
t = A()[1:2]
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
A()[1:2:3]
diff --git a/tests/basics/special_methods2.py b/tests/basics/special_methods2.py
index 3623b30dc..ba7cf27cd 100644
--- a/tests/basics/special_methods2.py
+++ b/tests/basics/special_methods2.py
@@ -100,9 +100,8 @@ cud2 = Cud()
try:
+cud1
except TypeError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# the following require MICROPY_PY_ALL_SPECIAL_METHODS
+cud1
diff --git a/tests/basics/string_center.py b/tests/basics/string_center.py
index a2739201a..40e8af4b8 100644
--- a/tests/basics/string_center.py
+++ b/tests/basics/string_center.py
@@ -1,9 +1,8 @@
try:
str.center
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print("foo".center(0))
print("foo".center(1))
diff --git a/tests/basics/string_partition.py b/tests/basics/string_partition.py
index b3b2f0907..bc36388fd 100644
--- a/tests/basics/string_partition.py
+++ b/tests/basics/string_partition.py
@@ -2,8 +2,7 @@ try:
str.partition
except AttributeError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
print("asdf".partition('g'))
print("asdf".partition('a'))
diff --git a/tests/basics/string_rpartition.py b/tests/basics/string_rpartition.py
index 84e0031fb..6d65dfaf2 100644
--- a/tests/basics/string_rpartition.py
+++ b/tests/basics/string_rpartition.py
@@ -2,8 +2,7 @@ try:
str.partition
except AttributeError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
print("asdf".rpartition('g'))
print("asdf".rpartition('a'))
diff --git a/tests/basics/string_rsplit.py b/tests/basics/string_rsplit.py
index 563b64f1c..b92b8f359 100644
--- a/tests/basics/string_rsplit.py
+++ b/tests/basics/string_rsplit.py
@@ -52,3 +52,7 @@ print("/*10/*11/*12/*".rsplit("/*", 4))
print("/*10/*11/*12/*".rsplit("/*", 5))
print(b"abcabc".rsplit(b"bc", 2))
+
+# negative "maxsplit" should delegate to .split()
+print('abaca'.rsplit('a', -1))
+print('abaca'.rsplit('a', -2))
diff --git a/tests/basics/string_splitlines.py b/tests/basics/string_splitlines.py
index 1d08f6e6d..c4c3fcb80 100644
--- a/tests/basics/string_splitlines.py
+++ b/tests/basics/string_splitlines.py
@@ -3,9 +3,8 @@
try:
str.splitlines
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# test \n as newline
print("foo\nbar".splitlines())
diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py
index bb6877c78..a442beb1e 100644
--- a/tests/basics/struct1.py
+++ b/tests/basics/struct1.py
@@ -4,9 +4,8 @@ except:
try:
import struct
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(struct.calcsize("<bI"))
print(struct.unpack("<bI", b"\x80\0\0\x01\0"))
diff --git a/tests/basics/struct1_intbig.py b/tests/basics/struct1_intbig.py
index 7f4c3ce12..b1fec527e 100644
--- a/tests/basics/struct1_intbig.py
+++ b/tests/basics/struct1_intbig.py
@@ -4,9 +4,8 @@ except:
try:
import struct
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# check maximum pack on 32-bit machine
print(struct.pack("<I", 2**32 - 1))
diff --git a/tests/basics/struct2.py b/tests/basics/struct2.py
index e3f8bbebf..d8234d0d3 100644
--- a/tests/basics/struct2.py
+++ b/tests/basics/struct2.py
@@ -6,9 +6,8 @@ except:
try:
import struct
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(struct.calcsize('0s'))
print(struct.unpack('0s', b''))
diff --git a/tests/basics/struct_micropython.py b/tests/basics/struct_micropython.py
index 53306dad6..4b9dfe137 100644
--- a/tests/basics/struct_micropython.py
+++ b/tests/basics/struct_micropython.py
@@ -6,9 +6,8 @@ except:
try:
import struct
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
class A():
pass
diff --git a/tests/basics/subclass_classmethod.py b/tests/basics/subclass_classmethod.py
index 48f164b36..00a2ebd7c 100644
--- a/tests/basics/subclass_classmethod.py
+++ b/tests/basics/subclass_classmethod.py
@@ -8,9 +8,8 @@ class Base:
try:
Base.__name__
except AttributeError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
class Sub(Base):
pass
diff --git a/tests/basics/sys1.py b/tests/basics/sys1.py
index 29ef974d1..0d74a1292 100644
--- a/tests/basics/sys1.py
+++ b/tests/basics/sys1.py
@@ -20,7 +20,7 @@ except AttributeError:
print(True)
try:
- sys.exit()
+ raise SystemExit
except SystemExit as e:
print("SystemExit", e.args)
diff --git a/tests/basics/try_reraise2.py b/tests/basics/try_reraise2.py
index d9434397c..5648d2467 100644
--- a/tests/basics/try_reraise2.py
+++ b/tests/basics/try_reraise2.py
@@ -1,4 +1,4 @@
-# Reraise not the latest occured exception
+# Reraise not the latest occurred exception
def f():
try:
raise ValueError("val", 3)
diff --git a/tests/basics/zip.py b/tests/basics/zip.py
index 958addb7a..66f2544e5 100644
--- a/tests/basics/zip.py
+++ b/tests/basics/zip.py
@@ -3,8 +3,7 @@ try:
set
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
print(list(zip()))
print(list(zip([1], set([2, 3]))))
diff --git a/tests/extmod/btree1.py b/tests/extmod/btree1.py
index 2127554db..59638ef0a 100644
--- a/tests/extmod/btree1.py
+++ b/tests/extmod/btree1.py
@@ -4,8 +4,7 @@ try:
import uerrno
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
#f = open("_test.db", "w+b")
f = uio.BytesIO()
diff --git a/tests/extmod/framebuf1.py b/tests/extmod/framebuf1.py
index 990b0b120..2c1366522 100644
--- a/tests/extmod/framebuf1.py
+++ b/tests/extmod/framebuf1.py
@@ -2,8 +2,7 @@ try:
import framebuf
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
w = 5
h = 16
diff --git a/tests/extmod/framebuf16.py b/tests/extmod/framebuf16.py
index 3aa1d34de..fe81f7f93 100644
--- a/tests/extmod/framebuf16.py
+++ b/tests/extmod/framebuf16.py
@@ -2,8 +2,7 @@ try:
import framebuf
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
def printbuf():
print("--8<--")
diff --git a/tests/extmod/framebuf4.py b/tests/extmod/framebuf4.py
index 641f5bfc5..8358fa55b 100644
--- a/tests/extmod/framebuf4.py
+++ b/tests/extmod/framebuf4.py
@@ -2,8 +2,7 @@ try:
import framebuf
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
def printbuf():
print("--8<--")
diff --git a/tests/extmod/machine1.py b/tests/extmod/machine1.py
index e0c561168..6ff38cc05 100644
--- a/tests/extmod/machine1.py
+++ b/tests/extmod/machine1.py
@@ -8,8 +8,7 @@ try:
machine.mem8
except:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
print(machine.mem8)
diff --git a/tests/extmod/machine_pinbase.py b/tests/extmod/machine_pinbase.py
index 5e82823ec..e91775504 100644
--- a/tests/extmod/machine_pinbase.py
+++ b/tests/extmod/machine_pinbase.py
@@ -6,8 +6,7 @@ try:
machine.PinBase
except AttributeError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
class MyPin(machine.PinBase):
diff --git a/tests/extmod/machine_pulse.py b/tests/extmod/machine_pulse.py
index 6491b5409..d525974e0 100644
--- a/tests/extmod/machine_pulse.py
+++ b/tests/extmod/machine_pulse.py
@@ -7,8 +7,7 @@ try:
machine.time_pulse_us
except AttributeError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
class ConstPin(machine.PinBase):
diff --git a/tests/extmod/machine_signal.py b/tests/extmod/machine_signal.py
index 96b8f43c7..53f4f5890 100644
--- a/tests/extmod/machine_signal.py
+++ b/tests/extmod/machine_signal.py
@@ -9,8 +9,7 @@ try:
machine.Signal
except AttributeError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
class Pin(machine.PinBase):
def __init__(self):
diff --git a/tests/extmod/time_ms_us.py b/tests/extmod/time_ms_us.py
index 2078f1bb5..31f07d31b 100644
--- a/tests/extmod/time_ms_us.py
+++ b/tests/extmod/time_ms_us.py
@@ -1,10 +1,9 @@
-import sys
import utime
try:
utime.sleep_ms
except AttributeError:
print("SKIP")
- sys.exit()
+ raise SystemExit
utime.sleep_ms(1)
utime.sleep_us(1)
diff --git a/tests/extmod/ubinascii_a2b_base64.py b/tests/extmod/ubinascii_a2b_base64.py
index 58eb0b50b..b35f26591 100644
--- a/tests/extmod/ubinascii_a2b_base64.py
+++ b/tests/extmod/ubinascii_a2b_base64.py
@@ -4,9 +4,8 @@ try:
except ImportError:
import binascii
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(binascii.a2b_base64(b''))
print(binascii.a2b_base64(b'Zg=='))
diff --git a/tests/extmod/ubinascii_b2a_base64.py b/tests/extmod/ubinascii_b2a_base64.py
index 1c0c30311..f4bb69fe0 100644
--- a/tests/extmod/ubinascii_b2a_base64.py
+++ b/tests/extmod/ubinascii_b2a_base64.py
@@ -4,9 +4,8 @@ try:
except ImportError:
import binascii
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(binascii.b2a_base64(b''))
print(binascii.b2a_base64(b'f'))
diff --git a/tests/extmod/ubinascii_crc32.py b/tests/extmod/ubinascii_crc32.py
index b82c44d6b..89664a9b3 100644
--- a/tests/extmod/ubinascii_crc32.py
+++ b/tests/extmod/ubinascii_crc32.py
@@ -4,16 +4,14 @@ try:
except ImportError:
import binascii
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
binascii.crc32
except AttributeError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
print(hex(binascii.crc32(b'The quick brown fox jumps over the lazy dog')))
print(hex(binascii.crc32(b'\x00' * 32)))
diff --git a/tests/extmod/ubinascii_hexlify.py b/tests/extmod/ubinascii_hexlify.py
index 5d70bda96..bc9928747 100644
--- a/tests/extmod/ubinascii_hexlify.py
+++ b/tests/extmod/ubinascii_hexlify.py
@@ -4,9 +4,8 @@ try:
except ImportError:
import binascii
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(binascii.hexlify(b'\x00\x01\x02\x03\x04\x05\x06\x07'))
print(binascii.hexlify(b'\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'))
diff --git a/tests/extmod/ubinascii_micropython.py b/tests/extmod/ubinascii_micropython.py
index 96f566bd1..a4c00a2cb 100644
--- a/tests/extmod/ubinascii_micropython.py
+++ b/tests/extmod/ubinascii_micropython.py
@@ -4,9 +4,8 @@ try:
except ImportError:
import binascii
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# two arguments supported in uPy but not CPython
a = binascii.hexlify(b'123', ':')
diff --git a/tests/extmod/ubinascii_unhexlify.py b/tests/extmod/ubinascii_unhexlify.py
index e669789ba..865abfe3a 100644
--- a/tests/extmod/ubinascii_unhexlify.py
+++ b/tests/extmod/ubinascii_unhexlify.py
@@ -4,9 +4,8 @@ try:
except ImportError:
import binascii
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(binascii.unhexlify(b'0001020304050607'))
print(binascii.unhexlify(b'08090a0b0c0d0e0f'))
diff --git a/tests/extmod/uctypes_32bit_intbig.py b/tests/extmod/uctypes_32bit_intbig.py
index a082dc370..6b4d3d76c 100644
--- a/tests/extmod/uctypes_32bit_intbig.py
+++ b/tests/extmod/uctypes_32bit_intbig.py
@@ -3,9 +3,8 @@
try:
import uctypes
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
buf = b"12345678abcd"
struct = uctypes.struct(
diff --git a/tests/extmod/uctypes_array_assign_le.py b/tests/extmod/uctypes_array_assign_le.py
index bae467d09..6afa7e0a2 100644
--- a/tests/extmod/uctypes_array_assign_le.py
+++ b/tests/extmod/uctypes_array_assign_le.py
@@ -1,9 +1,8 @@
try:
import uctypes
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
# arr is array at offset 0, of UINT8 elements, array size is 2
diff --git a/tests/extmod/uctypes_array_assign_native_le.py b/tests/extmod/uctypes_array_assign_native_le.py
index f0ecc0dad..a538bf9ad 100644
--- a/tests/extmod/uctypes_array_assign_native_le.py
+++ b/tests/extmod/uctypes_array_assign_native_le.py
@@ -3,11 +3,11 @@ try:
import uctypes
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
if sys.byteorder != "little":
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
# arr is array at offset 0, of UINT8 elements, array size is 2
diff --git a/tests/extmod/uctypes_array_assign_native_le_intbig.py b/tests/extmod/uctypes_array_assign_native_le_intbig.py
index f29a3b66e..84dfba0e2 100644
--- a/tests/extmod/uctypes_array_assign_native_le_intbig.py
+++ b/tests/extmod/uctypes_array_assign_native_le_intbig.py
@@ -3,11 +3,11 @@ try:
import uctypes
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
if sys.byteorder != "little":
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
# arr is array at offset 0, of UINT8 elements, array size is 2
diff --git a/tests/extmod/uctypes_bytearray.py b/tests/extmod/uctypes_bytearray.py
index bf7845ab2..61c7da271 100644
--- a/tests/extmod/uctypes_bytearray.py
+++ b/tests/extmod/uctypes_bytearray.py
@@ -1,9 +1,8 @@
try:
import uctypes
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
"arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),
diff --git a/tests/extmod/uctypes_le.py b/tests/extmod/uctypes_le.py
index 829beda58..7df5ac090 100644
--- a/tests/extmod/uctypes_le.py
+++ b/tests/extmod/uctypes_le.py
@@ -1,9 +1,8 @@
try:
import uctypes
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
"s0": uctypes.UINT16 | 0,
diff --git a/tests/extmod/uctypes_le_float.py b/tests/extmod/uctypes_le_float.py
index a61305ba8..84ff2b84c 100644
--- a/tests/extmod/uctypes_le_float.py
+++ b/tests/extmod/uctypes_le_float.py
@@ -1,9 +1,8 @@
try:
import uctypes
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
"f32": uctypes.FLOAT32 | 0,
diff --git a/tests/extmod/uctypes_native_float.py b/tests/extmod/uctypes_native_float.py
index 80cb54383..acef47036 100644
--- a/tests/extmod/uctypes_native_float.py
+++ b/tests/extmod/uctypes_native_float.py
@@ -1,9 +1,8 @@
try:
import uctypes
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
"f32": uctypes.FLOAT32 | 0,
diff --git a/tests/extmod/uctypes_native_le.py b/tests/extmod/uctypes_native_le.py
index 5900224d4..8bba03b38 100644
--- a/tests/extmod/uctypes_native_le.py
+++ b/tests/extmod/uctypes_native_le.py
@@ -6,11 +6,11 @@ try:
import uctypes
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
if sys.byteorder != "little":
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
diff --git a/tests/extmod/uctypes_print.py b/tests/extmod/uctypes_print.py
index 76a009dc7..c310238e5 100644
--- a/tests/extmod/uctypes_print.py
+++ b/tests/extmod/uctypes_print.py
@@ -2,9 +2,8 @@
try:
import uctypes
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# we use an address of "0" because we just want to print something deterministic
# and don't actually need to set/get any values in the struct
diff --git a/tests/extmod/uctypes_ptr_le.py b/tests/extmod/uctypes_ptr_le.py
index e8a6243ce..056e45650 100644
--- a/tests/extmod/uctypes_ptr_le.py
+++ b/tests/extmod/uctypes_ptr_le.py
@@ -3,11 +3,11 @@ try:
import uctypes
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
if sys.byteorder != "little":
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
"ptr": (uctypes.PTR | 0, uctypes.UINT8),
diff --git a/tests/extmod/uctypes_ptr_native_le.py b/tests/extmod/uctypes_ptr_native_le.py
index 9b016c04d..24508b1cb 100644
--- a/tests/extmod/uctypes_ptr_native_le.py
+++ b/tests/extmod/uctypes_ptr_native_le.py
@@ -3,11 +3,11 @@ try:
import uctypes
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
if sys.byteorder != "little":
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
diff --git a/tests/extmod/uctypes_sizeof.py b/tests/extmod/uctypes_sizeof.py
index 266cd0694..5a6adb437 100644
--- a/tests/extmod/uctypes_sizeof.py
+++ b/tests/extmod/uctypes_sizeof.py
@@ -1,9 +1,8 @@
try:
import uctypes
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
desc = {
# arr is array at offset 0, of UINT8 elements, array size is 2
diff --git a/tests/extmod/uctypes_sizeof_native.py b/tests/extmod/uctypes_sizeof_native.py
index f676c8c6d..32c740e77 100644
--- a/tests/extmod/uctypes_sizeof_native.py
+++ b/tests/extmod/uctypes_sizeof_native.py
@@ -1,9 +1,8 @@
try:
import uctypes
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
S1 = {}
assert uctypes.sizeof(S1) == 0
diff --git a/tests/extmod/uhashlib_sha1.py b/tests/extmod/uhashlib_sha1.py
index f12fc649a..4f7066899 100644
--- a/tests/extmod/uhashlib_sha1.py
+++ b/tests/extmod/uhashlib_sha1.py
@@ -1,4 +1,3 @@
-import sys
try:
import uhashlib as hashlib
except ImportError:
@@ -8,14 +7,14 @@ except ImportError:
# This is neither uPy, nor cPy, so must be uPy with
# uhashlib module disabled.
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
hashlib.sha1
except AttributeError:
# SHA1 is only available on some ports
print("SKIP")
- sys.exit()
+ raise SystemExit
sha1 = hashlib.sha1(b'hello')
sha1.update(b'world')
diff --git a/tests/extmod/uhashlib_sha256.py b/tests/extmod/uhashlib_sha256.py
index ff51f2ffa..3200e8f5c 100644
--- a/tests/extmod/uhashlib_sha256.py
+++ b/tests/extmod/uhashlib_sha256.py
@@ -1,4 +1,3 @@
-import sys
try:
import uhashlib as hashlib
except ImportError:
@@ -8,7 +7,7 @@ except ImportError:
# This is neither uPy, nor cPy, so must be uPy with
# uhashlib module disabled.
print("SKIP")
- sys.exit()
+ raise SystemExit
h = hashlib.sha256()
diff --git a/tests/extmod/uheapq1.py b/tests/extmod/uheapq1.py
index 4b0e5de57..7c1fe4e1e 100644
--- a/tests/extmod/uheapq1.py
+++ b/tests/extmod/uheapq1.py
@@ -4,9 +4,8 @@ except:
try:
import heapq
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
heapq.heappop([])
diff --git a/tests/extmod/ujson_dumps.py b/tests/extmod/ujson_dumps.py
index 4a02f5170..d73271801 100644
--- a/tests/extmod/ujson_dumps.py
+++ b/tests/extmod/ujson_dumps.py
@@ -4,9 +4,8 @@ except ImportError:
try:
import json
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(json.dumps(False))
print(json.dumps(True))
diff --git a/tests/extmod/ujson_dumps_extra.py b/tests/extmod/ujson_dumps_extra.py
index a52e8224c..21a388c32 100644
--- a/tests/extmod/ujson_dumps_extra.py
+++ b/tests/extmod/ujson_dumps_extra.py
@@ -3,8 +3,7 @@
try:
import ujson
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(ujson.dumps(b'1234'))
diff --git a/tests/extmod/ujson_dumps_float.py b/tests/extmod/ujson_dumps_float.py
index d949ea6dd..e8cceb6f1 100644
--- a/tests/extmod/ujson_dumps_float.py
+++ b/tests/extmod/ujson_dumps_float.py
@@ -4,8 +4,7 @@ except ImportError:
try:
import json
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(json.dumps(1.2))
diff --git a/tests/extmod/ujson_load.py b/tests/extmod/ujson_load.py
index 901132a5f..9725ab2dd 100644
--- a/tests/extmod/ujson_load.py
+++ b/tests/extmod/ujson_load.py
@@ -6,9 +6,8 @@ except:
from io import StringIO
import json
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(json.load(StringIO('null')))
print(json.load(StringIO('"abc\\u0064e"')))
diff --git a/tests/extmod/ujson_loads.py b/tests/extmod/ujson_loads.py
index b2e18e3af..adba3c068 100644
--- a/tests/extmod/ujson_loads.py
+++ b/tests/extmod/ujson_loads.py
@@ -4,9 +4,8 @@ except ImportError:
try:
import json
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
def my_print(o):
if isinstance(o, dict):
diff --git a/tests/extmod/ujson_loads_float.py b/tests/extmod/ujson_loads_float.py
index b20a412ff..f1b8cc364 100644
--- a/tests/extmod/ujson_loads_float.py
+++ b/tests/extmod/ujson_loads_float.py
@@ -4,9 +4,8 @@ except ImportError:
try:
import json
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
def my_print(o):
print('%.3f' % o)
diff --git a/tests/extmod/urandom_basic.py b/tests/extmod/urandom_basic.py
index 885b8517f..57e6b26cb 100644
--- a/tests/extmod/urandom_basic.py
+++ b/tests/extmod/urandom_basic.py
@@ -4,9 +4,8 @@ except ImportError:
try:
import random
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# check getrandbits returns a value within the bit range
for b in (1, 2, 3, 4, 16, 32):
diff --git a/tests/extmod/urandom_extra.py b/tests/extmod/urandom_extra.py
index 925dd0dbc..f5a34e168 100644
--- a/tests/extmod/urandom_extra.py
+++ b/tests/extmod/urandom_extra.py
@@ -4,16 +4,14 @@ except ImportError:
try:
import random
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
random.randint
except AttributeError:
- import sys
print('SKIP')
- sys.exit()
+ raise SystemExit
print('randrange')
for i in range(50):
diff --git a/tests/extmod/ure1.py b/tests/extmod/ure1.py
index a867f1751..1f38b8087 100644
--- a/tests/extmod/ure1.py
+++ b/tests/extmod/ure1.py
@@ -4,9 +4,8 @@ except ImportError:
try:
import re
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
r = re.compile(".+")
m = r.match("abc")
diff --git a/tests/extmod/ure_debug.py b/tests/extmod/ure_debug.py
index 252df21e3..cfb264bb6 100644
--- a/tests/extmod/ure_debug.py
+++ b/tests/extmod/ure_debug.py
@@ -2,8 +2,7 @@
try:
import ure
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
ure.compile('^a|b[0-9]\w$', ure.DEBUG)
diff --git a/tests/extmod/ure_error.py b/tests/extmod/ure_error.py
index 3f16f9158..f52f735c7 100644
--- a/tests/extmod/ure_error.py
+++ b/tests/extmod/ure_error.py
@@ -6,9 +6,8 @@ except ImportError:
try:
import re
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
def test_re(r):
try:
diff --git a/tests/extmod/ure_group.py b/tests/extmod/ure_group.py
index 98aae2a73..4e39468c5 100644
--- a/tests/extmod/ure_group.py
+++ b/tests/extmod/ure_group.py
@@ -6,9 +6,8 @@ except ImportError:
try:
import re
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
def print_groups(match):
print('----')
diff --git a/tests/extmod/ure_namedclass.py b/tests/extmod/ure_namedclass.py
index e233f17c8..215d09613 100644
--- a/tests/extmod/ure_namedclass.py
+++ b/tests/extmod/ure_namedclass.py
@@ -6,9 +6,8 @@ except ImportError:
try:
import re
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
def print_groups(match):
print('----')
diff --git a/tests/extmod/ure_split.py b/tests/extmod/ure_split.py
index 1e411c27c..317ca9892 100644
--- a/tests/extmod/ure_split.py
+++ b/tests/extmod/ure_split.py
@@ -4,9 +4,8 @@ except ImportError:
try:
import re
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
r = re.compile(" ")
s = r.split("a b c foobar")
diff --git a/tests/extmod/ure_split_empty.py b/tests/extmod/ure_split_empty.py
index ad6334eba..76ce97ea6 100644
--- a/tests/extmod/ure_split_empty.py
+++ b/tests/extmod/ure_split_empty.py
@@ -7,9 +7,8 @@
try:
import ure as re
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
r = re.compile(" *")
s = r.split("a b c foobar")
diff --git a/tests/extmod/ure_split_notimpl.py b/tests/extmod/ure_split_notimpl.py
index eca3ea512..da6e9652d 100644
--- a/tests/extmod/ure_split_notimpl.py
+++ b/tests/extmod/ure_split_notimpl.py
@@ -1,9 +1,8 @@
try:
import ure as re
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
r = re.compile('( )')
try:
diff --git a/tests/extmod/ussl_basic.py b/tests/extmod/ussl_basic.py
index e9d435bca..9f8019a0b 100644
--- a/tests/extmod/ussl_basic.py
+++ b/tests/extmod/ussl_basic.py
@@ -5,8 +5,7 @@ try:
import ussl as ssl
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
# create in client mode
try:
diff --git a/tests/extmod/utimeq1.py b/tests/extmod/utimeq1.py
index 68d69e25e..dc7f3b660 100644
--- a/tests/extmod/utimeq1.py
+++ b/tests/extmod/utimeq1.py
@@ -5,8 +5,7 @@ try:
from utimeq import utimeq
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
DEBUG = 0
diff --git a/tests/extmod/utimeq_stable.py b/tests/extmod/utimeq_stable.py
index 9f6ba76d4..9fb522d51 100644
--- a/tests/extmod/utimeq_stable.py
+++ b/tests/extmod/utimeq_stable.py
@@ -2,8 +2,7 @@ try:
from utimeq import utimeq
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
h = utimeq(10)
diff --git a/tests/extmod/uzlib_decompio.py b/tests/extmod/uzlib_decompio.py
index 6f07c048c..112a82597 100644
--- a/tests/extmod/uzlib_decompio.py
+++ b/tests/extmod/uzlib_decompio.py
@@ -2,9 +2,8 @@ try:
import uzlib as zlib
import uio as io
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# Raw DEFLATE bitstream
diff --git a/tests/extmod/uzlib_decompio_gz.py b/tests/extmod/uzlib_decompio_gz.py
index 7572e9693..02087f763 100644
--- a/tests/extmod/uzlib_decompio_gz.py
+++ b/tests/extmod/uzlib_decompio_gz.py
@@ -2,9 +2,8 @@ try:
import uzlib as zlib
import uio as io
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# gzip bitstream
diff --git a/tests/extmod/uzlib_decompress.py b/tests/extmod/uzlib_decompress.py
index 10121ee7e..63247955c 100644
--- a/tests/extmod/uzlib_decompress.py
+++ b/tests/extmod/uzlib_decompress.py
@@ -4,9 +4,8 @@ except ImportError:
try:
import uzlib as zlib
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
PATTERNS = [
# Packed results produced by CPy's zlib.compress()
diff --git a/tests/extmod/vfs_basic.py b/tests/extmod/vfs_basic.py
index a3b2f3c29..4fc67d34b 100644
--- a/tests/extmod/vfs_basic.py
+++ b/tests/extmod/vfs_basic.py
@@ -9,8 +9,7 @@ try:
uos.mount
except (ImportError, AttributeError):
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
class Filesystem:
@@ -57,6 +56,9 @@ for path in uos.listdir('/'):
# stat root dir
print(uos.stat('/'))
+# statvfs root dir; verify that f_namemax has a sensible size
+print(uos.statvfs('/')[9] >= 32)
+
# getcwd when in root dir
print(uos.getcwd())
@@ -128,6 +130,8 @@ except OSError:
# root dir
uos.mount(Filesystem(3), '/')
+print(uos.stat('/'))
+print(uos.statvfs('/'))
print(uos.listdir())
open('test')
diff --git a/tests/extmod/vfs_basic.py.exp b/tests/extmod/vfs_basic.py.exp
index 8a23aa8ae..0ae2c2cc9 100644
--- a/tests/extmod/vfs_basic.py.exp
+++ b/tests/extmod/vfs_basic.py.exp
@@ -1,4 +1,5 @@
(16384, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+True
/
1 mount False False
['test_mnt']
@@ -36,6 +37,9 @@ OSError
2 umount
OSError
3 mount False False
+(16384, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+3 statvfs /
+(3,)
3 ilistdir /
['a3']
3 open test r
diff --git a/tests/extmod/vfs_fat_fileio1.py b/tests/extmod/vfs_fat_fileio1.py
index 9036df7a5..d19df120b 100644
--- a/tests/extmod/vfs_fat_fileio1.py
+++ b/tests/extmod/vfs_fat_fileio1.py
@@ -1,4 +1,3 @@
-import sys
try:
import uerrno
try:
@@ -8,13 +7,13 @@ try:
import uos
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
uos.VfsFat
except AttributeError:
print("SKIP")
- sys.exit()
+ raise SystemExit
class RAMFS:
@@ -46,7 +45,7 @@ try:
bdev = RAMFS(50)
except MemoryError:
print("SKIP")
- sys.exit()
+ raise SystemExit
uos.VfsFat.mkfs(bdev)
vfs = uos.VfsFat(bdev)
diff --git a/tests/extmod/vfs_fat_fileio2.py b/tests/extmod/vfs_fat_fileio2.py
index b2a0ba70f..b5adb75c9 100644
--- a/tests/extmod/vfs_fat_fileio2.py
+++ b/tests/extmod/vfs_fat_fileio2.py
@@ -1,4 +1,3 @@
-import sys
try:
import uerrno
try:
@@ -8,13 +7,13 @@ try:
import uos
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
uos.VfsFat
except AttributeError:
print("SKIP")
- sys.exit()
+ raise SystemExit
class RAMFS:
@@ -46,7 +45,7 @@ try:
bdev = RAMFS(50)
except MemoryError:
print("SKIP")
- sys.exit()
+ raise SystemExit
uos.VfsFat.mkfs(bdev)
vfs = uos.VfsFat(bdev)
diff --git a/tests/extmod/vfs_fat_more.py b/tests/extmod/vfs_fat_more.py
index dacb21553..baec96787 100644
--- a/tests/extmod/vfs_fat_more.py
+++ b/tests/extmod/vfs_fat_more.py
@@ -1,4 +1,3 @@
-import sys
import uerrno
try:
try:
@@ -8,13 +7,13 @@ try:
import uos
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
uos.VfsFat
except AttributeError:
print("SKIP")
- sys.exit()
+ raise SystemExit
class RAMFS:
@@ -47,7 +46,7 @@ try:
bdev2 = RAMFS(50)
except MemoryError:
print("SKIP")
- sys.exit()
+ raise SystemExit
# first we umount any existing mount points the target may have
try:
diff --git a/tests/extmod/vfs_fat_oldproto.py b/tests/extmod/vfs_fat_oldproto.py
index 3e66758c3..ef4f1da78 100644
--- a/tests/extmod/vfs_fat_oldproto.py
+++ b/tests/extmod/vfs_fat_oldproto.py
@@ -1,4 +1,3 @@
-import sys
try:
import uerrno
try:
@@ -7,13 +6,13 @@ try:
import uos
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
uos.VfsFat
except AttributeError:
print("SKIP")
- sys.exit()
+ raise SystemExit
class RAMFS_OLD:
@@ -43,7 +42,7 @@ try:
bdev = RAMFS_OLD(50)
except MemoryError:
print("SKIP")
- sys.exit()
+ raise SystemExit
uos.VfsFat.mkfs(bdev)
vfs = uos.VfsFat(bdev)
diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py
index fe72a8bef..801c69786 100644
--- a/tests/extmod/vfs_fat_ramdisk.py
+++ b/tests/extmod/vfs_fat_ramdisk.py
@@ -1,4 +1,3 @@
-import sys
try:
import uerrno
try:
@@ -7,13 +6,13 @@ try:
import uos
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
uos.VfsFat
except AttributeError:
print("SKIP")
- sys.exit()
+ raise SystemExit
class RAMFS:
@@ -45,7 +44,7 @@ try:
bdev = RAMFS(50)
except MemoryError:
print("SKIP")
- sys.exit()
+ raise SystemExit
uos.VfsFat.mkfs(bdev)
diff --git a/tests/extmod/websocket_basic.py b/tests/extmod/websocket_basic.py
index 770836c8e..9a80503a0 100644
--- a/tests/extmod/websocket_basic.py
+++ b/tests/extmod/websocket_basic.py
@@ -3,9 +3,8 @@ try:
import uerrno
import websocket
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# put raw data in the stream and do a websocket read
def ws_read(msg, sz):
diff --git a/tests/float/array_construct.py b/tests/float/array_construct.py
index 7e01fd476..938675835 100644
--- a/tests/float/array_construct.py
+++ b/tests/float/array_construct.py
@@ -3,9 +3,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(array('f', array('h', [1, 2])))
print(array('d', array('f', [1, 2])))
diff --git a/tests/float/builtin_float_minmax.py b/tests/float/builtin_float_minmax.py
index 42cfa6382..266ed133d 100644
--- a/tests/float/builtin_float_minmax.py
+++ b/tests/float/builtin_float_minmax.py
@@ -3,31 +3,30 @@ try:
min
max
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
-print(min(0,1.0))
-print(min(1.0,0))
-print(min(0,-1.0))
-print(min(-1.0,0))
+print(min(0, 1.0))
+print(min(1.0, 0))
+print(min(0, -1.0))
+print(min(-1.0, 0))
-print(max(0,1.0))
-print(max(1.0,0))
-print(max(0,-1.0))
-print(max(-1.0,0))
+print(max(0, 1.0))
+print(max(1.0, 0))
+print(max(0, -1.0))
+print(max(-1.0, 0))
-print(min(1.5,-1.5))
-print(min(-1.5,1.5))
+print(min(1.5, -1.5))
+print(min(-1.5, 1.5))
-print(max(1.5,-1.5))
-print(max(-1.5,1.5))
+print(max(1.5, -1.5))
+print(max(-1.5, 1.5))
-print(min([1,2.9,4,0,-1,2]))
-print(max([1,2.9,4,0,-1,2]))
+print(min([1, 2.9, 4, 0, -1, 2]))
+print(max([1, 2.9, 4, 0, -1, 2]))
-print(min([1,2.9,4,6.5,-1,2]))
-print(max([1,2.9,4,6.5,-1,2]))
-print(min([1,2.9,4,-6.5,-1,2]))
-print(max([1,2.9,4,-6.5,-1,2]))
+print(min([1, 2.9, 4, 6.5, -1, 2]))
+print(max([1, 2.9, 4, 6.5, -1, 2]))
+print(min([1, 2.9, 4, -6.5, -1, 2]))
+print(max([1, 2.9, 4, -6.5, -1, 2]))
diff --git a/tests/float/bytearray_construct.py b/tests/float/bytearray_construct.py
index db946a99d..e960d624e 100644
--- a/tests/float/bytearray_construct.py
+++ b/tests/float/bytearray_construct.py
@@ -3,8 +3,7 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(bytearray(array('f', [1, 2.3])))
diff --git a/tests/float/bytes_construct.py b/tests/float/bytes_construct.py
index 8664d7296..0e4482e43 100644
--- a/tests/float/bytes_construct.py
+++ b/tests/float/bytes_construct.py
@@ -3,8 +3,7 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
print(bytes(array('f', [1, 2.3])))
diff --git a/tests/float/cmath_fun.py b/tests/float/cmath_fun.py
index 3ebcf5918..ae5921c30 100644
--- a/tests/float/cmath_fun.py
+++ b/tests/float/cmath_fun.py
@@ -4,8 +4,7 @@ try:
from cmath import *
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
# make sure these constants exist in cmath
print("%.5g" % e)
diff --git a/tests/float/cmath_fun_special.py b/tests/float/cmath_fun_special.py
index 422964dd7..471fda8c0 100644
--- a/tests/float/cmath_fun_special.py
+++ b/tests/float/cmath_fun_special.py
@@ -5,8 +5,7 @@ try:
log10
except (ImportError, NameError):
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
test_values_non_zero = []
base_values = (0.0, 0.5, 1.2345, 10.)
diff --git a/tests/float/float_array.py b/tests/float/float_array.py
index 8bc963444..8c8edcff7 100644
--- a/tests/float/float_array.py
+++ b/tests/float/float_array.py
@@ -1,9 +1,8 @@
try:
from array import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
def test(a):
print(a)
diff --git a/tests/float/float_struct.py b/tests/float/float_struct.py
index a36ccce38..c4c186b89 100644
--- a/tests/float/float_struct.py
+++ b/tests/float/float_struct.py
@@ -5,9 +5,8 @@ try:
except:
import struct
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
i = 1. + 1/2
# TODO: it looks like '=' format modifier is not yet supported
diff --git a/tests/float/math_fun.py b/tests/float/math_fun.py
index d9f179587..80d20bd8a 100644
--- a/tests/float/math_fun.py
+++ b/tests/float/math_fun.py
@@ -4,8 +4,7 @@ try:
from math import *
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
test_values = [-100., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 100.]
test_values_small = [-10., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 10.] # so we don't overflow 32-bit precision
diff --git a/tests/float/math_fun_bool.py b/tests/float/math_fun_bool.py
index 57232857a..30ab14a52 100644
--- a/tests/float/math_fun_bool.py
+++ b/tests/float/math_fun_bool.py
@@ -4,8 +4,7 @@ try:
from math import isfinite, isnan, isinf
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
test_values = [1, 0, -1, 1.0, 0.0, -1.0, float('NaN'), float('Inf'),
-float('NaN'), -float('Inf')]
diff --git a/tests/float/math_fun_int.py b/tests/float/math_fun_int.py
index ee54f0995..5cadbb1e5 100644
--- a/tests/float/math_fun_int.py
+++ b/tests/float/math_fun_int.py
@@ -4,8 +4,7 @@ try:
import math
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
for fun in (math.ceil, math.floor, math.trunc):
for x in (-1.6, -0.2, 0, 0.6, 1.4, float('inf'), float('nan')):
diff --git a/tests/float/math_fun_intbig.py b/tests/float/math_fun_intbig.py
index 962c10daa..697ca7a6d 100644
--- a/tests/float/math_fun_intbig.py
+++ b/tests/float/math_fun_intbig.py
@@ -4,8 +4,7 @@ try:
import math
except ImportError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
for fun in (math.ceil, math.floor, math.trunc):
for x in (-1e25, 1e25):
diff --git a/tests/float/math_fun_special.py b/tests/float/math_fun_special.py
index 32249b423..c3665a7cd 100644
--- a/tests/float/math_fun_special.py
+++ b/tests/float/math_fun_special.py
@@ -5,8 +5,7 @@ try:
erf
except (ImportError, NameError):
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
test_values = [-8., -2.5, -1, -0.5, 0.0, 0.5, 2.5, 8.,]
pos_test_values = [0.001, 0.1, 0.5, 1.0, 1.5, 10.,]
diff --git a/tests/io/buffered_writer.py b/tests/io/buffered_writer.py
index bb7b4e8db..c2cedb991 100644
--- a/tests/io/buffered_writer.py
+++ b/tests/io/buffered_writer.py
@@ -4,9 +4,8 @@ try:
io.BytesIO
io.BufferedWriter
except AttributeError:
- import sys
print('SKIP')
- sys.exit()
+ raise SystemExit
bts = io.BytesIO()
buf = io.BufferedWriter(bts, 8)
diff --git a/tests/io/bytesio_cow.py b/tests/io/bytesio_cow.py
new file mode 100644
index 000000000..92654a000
--- /dev/null
+++ b/tests/io/bytesio_cow.py
@@ -0,0 +1,20 @@
+# Make sure that write operations on io.BytesIO don't
+# change original object it was constructed from.
+try:
+ import uio as io
+except ImportError:
+ import io
+
+b = b"foobar"
+
+a = io.BytesIO(b)
+a.write(b"1")
+print(b)
+print(a.getvalue())
+
+b = bytearray(b"foobar")
+
+a = io.BytesIO(b)
+a.write(b"1")
+print(b)
+print(a.getvalue())
diff --git a/tests/io/open_append.py b/tests/io/open_append.py
index 2120b72f0..a696823bc 100644
--- a/tests/io/open_append.py
+++ b/tests/io/open_append.py
@@ -1,4 +1,3 @@
-import sys
try:
import uos as os
except ImportError:
@@ -6,7 +5,7 @@ except ImportError:
if not hasattr(os, "unlink"):
print("SKIP")
- sys.exit()
+ raise SystemExit
# cleanup in case testfile exists
try:
diff --git a/tests/io/open_plus.py b/tests/io/open_plus.py
index 98598ee67..bba96fa2f 100644
--- a/tests/io/open_plus.py
+++ b/tests/io/open_plus.py
@@ -1,4 +1,3 @@
-import sys
try:
import uos as os
except ImportError:
@@ -6,7 +5,7 @@ except ImportError:
if not hasattr(os, "unlink"):
print("SKIP")
- sys.exit()
+ raise SystemExit
# cleanup in case testfile exists
try:
diff --git a/tests/io/resource_stream.py b/tests/io/resource_stream.py
index 86975f118..37d985bf1 100644
--- a/tests/io/resource_stream.py
+++ b/tests/io/resource_stream.py
@@ -5,7 +5,7 @@ try:
uio.resource_stream
except AttributeError:
print('SKIP')
- sys.exit()
+ raise SystemExit
buf = uio.resource_stream("data", "file2")
print(buf.read())
diff --git a/tests/io/write_ext.py b/tests/io/write_ext.py
index 19b616174..5a6eaa35c 100644
--- a/tests/io/write_ext.py
+++ b/tests/io/write_ext.py
@@ -5,9 +5,8 @@ import uio
try:
uio.BytesIO
except AttributeError:
- import sys
print('SKIP')
- sys.exit()
+ raise SystemExit
buf = uio.BytesIO()
diff --git a/tests/jni/list.py b/tests/jni/list.py
index 6725abb5a..d58181d0b 100644
--- a/tests/jni/list.py
+++ b/tests/jni/list.py
@@ -1,10 +1,9 @@
-import sys
import jni
try:
ArrayList = jni.cls("java/util/ArrayList")
except:
print("SKIP")
- sys.exit()
+ raise SystemExit
l = ArrayList()
print(l)
diff --git a/tests/jni/object.py b/tests/jni/object.py
index 6cf936c4d..aa67615ec 100644
--- a/tests/jni/object.py
+++ b/tests/jni/object.py
@@ -1,10 +1,9 @@
-import sys
import jni
try:
Integer = jni.cls("java/lang/Integer")
except:
print("SKIP")
- sys.exit()
+ raise SystemExit
# Create object
i = Integer(42)
diff --git a/tests/jni/system_out.py b/tests/jni/system_out.py
index 7a1f18030..86c4b9e11 100644
--- a/tests/jni/system_out.py
+++ b/tests/jni/system_out.py
@@ -1,9 +1,8 @@
-import sys
try:
import jni
System = jni.cls("java/lang/System")
except:
print("SKIP")
- sys.exit()
+ raise SystemExit
System.out.println("Hello, Java!")
diff --git a/tests/micropython/heapalloc_bytesio.py b/tests/micropython/heapalloc_bytesio.py
index 2a8d50abe..4aae2abf0 100644
--- a/tests/micropython/heapalloc_bytesio.py
+++ b/tests/micropython/heapalloc_bytesio.py
@@ -1,9 +1,8 @@
try:
import uio
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
import micropython
diff --git a/tests/micropython/heapalloc_bytesio2.py b/tests/micropython/heapalloc_bytesio2.py
new file mode 100644
index 000000000..cd76f5807
--- /dev/null
+++ b/tests/micropython/heapalloc_bytesio2.py
@@ -0,0 +1,20 @@
+# Creating BytesIO from immutable object should not immediately
+# copy its content.
+try:
+ import uio
+ import micropython
+ micropython.mem_total
+except (ImportError, AttributeError):
+ print("SKIP")
+ raise SystemExit
+
+
+data = b"1234" * 256
+
+before = micropython.mem_total()
+
+buf = uio.BytesIO(data)
+
+after = micropython.mem_total()
+
+print(after - before < len(data))
diff --git a/tests/micropython/heapalloc_bytesio2.py.exp b/tests/micropython/heapalloc_bytesio2.py.exp
new file mode 100644
index 000000000..0ca95142b
--- /dev/null
+++ b/tests/micropython/heapalloc_bytesio2.py.exp
@@ -0,0 +1 @@
+True
diff --git a/tests/micropython/heapalloc_iter.py b/tests/micropython/heapalloc_iter.py
index 45d3519e4..79461f999 100644
--- a/tests/micropython/heapalloc_iter.py
+++ b/tests/micropython/heapalloc_iter.py
@@ -2,9 +2,8 @@
try:
import array
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
try:
from micropython import heap_lock, heap_unlock
diff --git a/tests/micropython/heapalloc_traceback.py b/tests/micropython/heapalloc_traceback.py
index b3795293f..f4212b6ce 100644
--- a/tests/micropython/heapalloc_traceback.py
+++ b/tests/micropython/heapalloc_traceback.py
@@ -5,9 +5,8 @@ import sys
try:
import uio
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# preallocate exception instance with some room for a traceback
global_exc = StopIteration()
diff --git a/tests/micropython/heapalloc_traceback.py.exp b/tests/micropython/heapalloc_traceback.py.exp
index facd0af13..291bbd697 100644
--- a/tests/micropython/heapalloc_traceback.py.exp
+++ b/tests/micropython/heapalloc_traceback.py.exp
@@ -1,5 +1,5 @@
StopIteration
Traceback (most recent call last):
- File , line 23, in test
+ File , line 22, in test
StopIteration:
diff --git a/tests/micropython/kbd_intr.py b/tests/micropython/kbd_intr.py
index a7ce7464b..879c9a229 100644
--- a/tests/micropython/kbd_intr.py
+++ b/tests/micropython/kbd_intr.py
@@ -6,8 +6,7 @@ try:
micropython.kbd_intr
except AttributeError:
print('SKIP')
- import sys
- sys.exit()
+ raise SystemExit
# just check we can actually call it
micropython.kbd_intr(3)
diff --git a/tests/micropython/schedule.py b/tests/micropython/schedule.py
index 3d584eea4..74f90cb2d 100644
--- a/tests/micropython/schedule.py
+++ b/tests/micropython/schedule.py
@@ -6,8 +6,7 @@ try:
micropython.schedule
except AttributeError:
print('SKIP')
- import sys
- sys.exit()
+ raise SystemExit
# Basic test of scheduling a function.
diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py
index 31074ab01..b4c90e9fc 100644
--- a/tests/misc/non_compliant.py
+++ b/tests/misc/non_compliant.py
@@ -4,9 +4,8 @@ try:
import array
import ustruct
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# when super can't find self
try:
diff --git a/tests/misc/print_exception.py b/tests/misc/print_exception.py
index b833a7981..9ab8e728b 100644
--- a/tests/misc/print_exception.py
+++ b/tests/misc/print_exception.py
@@ -6,7 +6,7 @@ try:
import io
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
if hasattr(sys, 'print_exception'):
print_exception = sys.print_exception
diff --git a/tests/misc/recursive_data.py b/tests/misc/recursive_data.py
index 383018945..3b7fa5095 100644
--- a/tests/misc/recursive_data.py
+++ b/tests/misc/recursive_data.py
@@ -2,9 +2,8 @@
try:
import uio as io
except ImportError:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
l = [1, 2, 3, None]
l[-1] = l
diff --git a/tests/misc/recursive_iternext.py b/tests/misc/recursive_iternext.py
index d90f17716..edb5a843f 100644
--- a/tests/misc/recursive_iternext.py
+++ b/tests/misc/recursive_iternext.py
@@ -6,9 +6,8 @@ try:
max
zip
except:
- import sys
print("SKIP")
- sys.exit()
+ raise SystemExit
# We need to pick an N that is large enough to hit the recursion
# limit, but not too large that we run out of heap memory.
diff --git a/tests/misc/sys_exc_info.py b/tests/misc/sys_exc_info.py
index de5b82562..4bb2c61e8 100644
--- a/tests/misc/sys_exc_info.py
+++ b/tests/misc/sys_exc_info.py
@@ -3,7 +3,7 @@ try:
sys.exc_info
except:
print("SKIP")
- sys.exit()
+ raise SystemExit
def f():
print(sys.exc_info()[0:2])
diff --git a/tests/pyb/can.py b/tests/pyb/can.py
index 617eb7ccc..0fd8c8368 100644
--- a/tests/pyb/can.py
+++ b/tests/pyb/can.py
@@ -2,8 +2,7 @@ try:
from pyb import CAN
except ImportError:
print('SKIP')
- import sys
- sys.exit()
+ raise SystemExit
import pyb
@@ -158,7 +157,7 @@ print(can.recv(1))
del can
-# Testing asyncronous send
+# Testing asynchronous send
can = CAN(1, CAN.LOOPBACK)
can.setfilter(0, CAN.MASK16, 0, (0, 0, 0, 0))
diff --git a/tests/pyb/dac.py b/tests/pyb/dac.py
index 942f30354..6f03bbc64 100644
--- a/tests/pyb/dac.py
+++ b/tests/pyb/dac.py
@@ -2,8 +2,7 @@ import pyb
if not hasattr(pyb, 'DAC'):
print('SKIP')
- import sys
- sys.exit()
+ raise SystemExit
dac = pyb.DAC(1)
print(dac)
diff --git a/tests/pyb/pyb_f405.py b/tests/pyb/pyb_f405.py
index 3c81fe109..2f161ae09 100644
--- a/tests/pyb/pyb_f405.py
+++ b/tests/pyb/pyb_f405.py
@@ -4,8 +4,7 @@ import os, pyb
if not 'STM32F405' in os.uname().machine:
print('SKIP')
- import sys
- sys.exit()
+ raise SystemExit
print(pyb.freq())
print(type(pyb.rng()))
diff --git a/tests/pyb/pyb_f411.py b/tests/pyb/pyb_f411.py
index 328653965..50de30282 100644
--- a/tests/pyb/pyb_f411.py
+++ b/tests/pyb/pyb_f411.py
@@ -4,7 +4,6 @@ import os, pyb
if not 'STM32F411' in os.uname().machine:
print('SKIP')
- import sys
- sys.exit()
+ raise SystemExit
print(pyb.freq())
diff --git a/tests/thread/stress_aes.py b/tests/thread/stress_aes.py
index ecc963c92..df75e616c 100644
--- a/tests/thread/stress_aes.py
+++ b/tests/thread/stress_aes.py
@@ -8,7 +8,7 @@
#
# The AES code comes first (code originates from a C version authored by D.P.George)
# and then the test harness at the bottom. It can be tuned to be more/less
-# agressive by changing the amount of data to encrypt, the number of loops and
+# aggressive by changing the amount of data to encrypt, the number of loops and
# the number of threads.
#
# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py
index 870e7d5f2..7a496aa87 100644
--- a/tests/unix/extra_coverage.py
+++ b/tests/unix/extra_coverage.py
@@ -2,8 +2,7 @@ try:
extra_coverage
except NameError:
print("SKIP")
- import sys
- sys.exit()
+ raise SystemExit
import uerrno
import uio
diff --git a/tests/unix/ffi_callback.py b/tests/unix/ffi_callback.py
index 7f8af15b3..23b058bce 100644
--- a/tests/unix/ffi_callback.py
+++ b/tests/unix/ffi_callback.py
@@ -1,9 +1,8 @@
-import sys
try:
import ffi
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
def ffi_open(names):
diff --git a/tests/unix/ffi_float.py b/tests/unix/ffi_float.py
index cc12fa7ad..c92a39bcd 100644
--- a/tests/unix/ffi_float.py
+++ b/tests/unix/ffi_float.py
@@ -1,10 +1,9 @@
# test ffi float support
-import sys
try:
import ffi
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
def ffi_open(names):
diff --git a/tests/unix/ffi_float2.py b/tests/unix/ffi_float2.py
index d635a2714..721eb4d19 100644
--- a/tests/unix/ffi_float2.py
+++ b/tests/unix/ffi_float2.py
@@ -1,10 +1,9 @@
# test ffi float support
-import sys
try:
import ffi
except ImportError:
print("SKIP")
- sys.exit()
+ raise SystemExit
def ffi_open(names):
@@ -25,7 +24,7 @@ try:
tgammaf = libm.func('f', 'tgammaf', 'f')
except OSError:
print("SKIP")
- sys.exit()
+ raise SystemExit
for fun in (tgammaf,):
for val in (0.5, 1, 1.0, 1.5, 4, 4.0):
diff --git a/tests/wipy/uart.py b/tests/wipy/uart.py
index a3a1c14e8..8e794015d 100644
--- a/tests/wipy/uart.py
+++ b/tests/wipy/uart.py
@@ -95,7 +95,7 @@ print(uart1.read() == None)
print(uart1.write(b'123') == 3)
print(uart0.read() == b'123')
-# no pin assignemnt
+# no pin assignment
uart0 = UART(0, 1000000, pins=(None, None))
print(uart0.write(b'123456789') == 9)
print(uart1.read() == None)
diff --git a/tools/insert-usb-ids.py b/tools/insert-usb-ids.py
index 420db34c5..cdccd3be9 100644
--- a/tools/insert-usb-ids.py
+++ b/tools/insert-usb-ids.py
@@ -1,4 +1,4 @@
-# Reads the USB VID and PID from the file specifed by sys.arg[1] and then
+# Reads the USB VID and PID from the file specified by sys.argv[1] and then
# inserts those values into the template file specified by sys.argv[2],
# printing the result to stdout
diff --git a/tools/pyboard.py b/tools/pyboard.py
index 5eac030bd..921ffc52d 100755
--- a/tools/pyboard.py
+++ b/tools/pyboard.py
@@ -69,7 +69,7 @@ class TelnetToSerial:
self.tn.write(bytes(password, 'ascii') + b"\r\n")
if b'for more information.' in self.tn.read_until(b'Type "help()" for more information.', timeout=read_timeout):
- # login succesful
+ # login successful
from collections import deque
self.fifo = deque()
return
diff --git a/unix/Makefile b/unix/Makefile
index 837ddf2b7..be324dd3d 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -262,7 +262,7 @@ coverage_test: coverage
gcov -o build-coverage/extmod ../extmod/*.c
# Value of configure's --host= option (required for cross-compilation).
-# Deduce it from CROSS_COMPILE by default, but can be overriden.
+# Deduce it from CROSS_COMPILE by default, but can be overridden.
ifneq ($(CROSS_COMPILE),)
CROSS_COMPILE_HOST = --host=$(patsubst %-,%,$(CROSS_COMPILE))
else
@@ -278,15 +278,15 @@ libffi:
cd ../lib/libffi; ./autogen.sh
mkdir -p ../lib/libffi/build_dir; cd ../lib/libffi/build_dir; \
../configure $(CROSS_COMPILE_HOST) --prefix=$$PWD/out --disable-structs CC="$(CC)" CXX="$(CXX)" LD="$(LD)" CFLAGS="-Os -fomit-frame-pointer -fstrict-aliasing -ffast-math -fno-exceptions"; \
- make install-exec-recursive; make -C include install-data-am
+ $(MAKE) install-exec-recursive; $(MAKE) -C include install-data-am
axtls: $(BUILD)/libaxtls.a
$(BUILD)/libaxtls.a: ../lib/axtls/README | $(OBJ_DIRS)
cd ../lib/axtls; cp config/upyconfig config/.config
- cd ../lib/axtls; make oldconfig -B
- cd ../lib/axtls; make clean
- cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)"
+ cd ../lib/axtls; $(MAKE) oldconfig -B
+ cd ../lib/axtls; $(MAKE) clean
+ cd ../lib/axtls; $(MAKE) all CC="$(CC)" LD="$(LD)"
cp ../lib/axtls/_stage/libaxtls.a $@
../lib/axtls/README:
diff --git a/unix/input.c b/unix/input.c
index 7cd527fed..4b10350df 100644
--- a/unix/input.c
+++ b/unix/input.c
@@ -37,32 +37,8 @@
#include "lib/mp-readline/readline.h"
#endif
+#if MICROPY_USE_READLINE == 0
char *prompt(char *p) {
-#if MICROPY_USE_READLINE == 1
- // MicroPython supplied readline
- vstr_t vstr;
- vstr_init(&vstr, 16);
- mp_hal_stdio_mode_raw();
- int ret = readline(&vstr, p);
- mp_hal_stdio_mode_orig();
- if (ret != 0) {
- vstr_clear(&vstr);
- if (ret == CHAR_CTRL_D) {
- // EOF
- printf("\n");
- return NULL;
- } else {
- printf("\n");
- char *line = malloc(1);
- line[0] = '\0';
- return line;
- }
- }
- vstr_null_terminated_str(&vstr);
- char *line = malloc(vstr.len + 1);
- memcpy(line, vstr.buf, vstr.len + 1);
- vstr_clear(&vstr);
-#else
// simple read string
static char buf[256];
fputs(p, stdout);
@@ -78,9 +54,9 @@ char *prompt(char *p) {
}
char *line = malloc(l);
memcpy(line, buf, l);
-#endif
return line;
}
+#endif
void prompt_read_history(void) {
#if MICROPY_USE_READLINE_HISTORY
@@ -143,18 +119,3 @@ void prompt_write_history(void) {
#endif
#endif
}
-
-STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
- if (n_args == 1) {
- mp_obj_print(args[0], PRINT_STR);
- }
-
- char *line = prompt("");
- if (line == NULL) {
- nlr_raise(mp_obj_new_exception(&mp_type_EOFError));
- }
- mp_obj_t o = mp_obj_new_str(line, strlen(line), false);
- free(line);
- return o;
-}
-MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input);
diff --git a/unix/modsocket.c b/unix/modsocket.c
index 9ca04b88b..c7be6461e 100644
--- a/unix/modsocket.c
+++ b/unix/modsocket.c
@@ -58,7 +58,7 @@
from socket_more_funcs2 import *
-------------------
I.e. this module should stay lean, and more functions (if needed)
- should be add to seperate modules (C or Python level).
+ should be add to separate modules (C or Python level).
*/
#define MICROPY_SOCKET_EXTRA (0)
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index d8b8e9d1e..047121fe6 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -81,6 +81,7 @@
#define MICROPY_PY_BUILTINS_FROZENSET (1)
#define MICROPY_PY_BUILTINS_COMPILE (1)
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
+#define MICROPY_PY_BUILTINS_INPUT (1)
#define MICROPY_PY_BUILTINS_POW3 (1)
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
@@ -279,7 +280,6 @@ void mp_unix_mark_exec(void);
#endif
#define MICROPY_PORT_BUILTINS \
- { MP_ROM_QSTR(MP_QSTR_input), MP_ROM_PTR(&mp_builtin_input_obj) }, \
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
#define MP_STATE_PORT MP_STATE_VM
diff --git a/unix/mphalport.h b/unix/mphalport.h
index 00e79ec17..cf227872f 100644
--- a/unix/mphalport.h
+++ b/unix/mphalport.h
@@ -34,6 +34,19 @@ void mp_hal_set_interrupt_char(char c);
void mp_hal_stdio_mode_raw(void);
void mp_hal_stdio_mode_orig(void);
+#if MICROPY_USE_READLINE == 1 && MICROPY_PY_BUILTINS_INPUT
+#include "py/misc.h"
+#include "lib/mp-readline/readline.h"
+// For built-in input() we need to wrap the standard readline() to enable raw mode
+#define mp_hal_readline mp_hal_readline
+static inline int mp_hal_readline(vstr_t *vstr, const char *p) {
+ mp_hal_stdio_mode_raw();
+ int ret = readline(vstr, p);
+ mp_hal_stdio_mode_orig();
+ return ret;
+}
+#endif
+
// TODO: POSIX et al. define usleep() as guaranteedly capable only of 1s sleep:
// "The useconds argument shall be less than one million."
static inline void mp_hal_delay_ms(mp_uint_t ms) { usleep((ms) * 1000); }
diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h
index 8cef50671..f2f6cbd32 100644
--- a/windows/mpconfigport.h
+++ b/windows/mpconfigport.h
@@ -69,6 +69,7 @@
#define MICROPY_PY_BUILTINS_FROZENSET (1)
#define MICROPY_PY_BUILTINS_COMPILE (1)
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
+#define MICROPY_PY_BUILTINS_INPUT (1)
#define MICROPY_PY_BUILTINS_POW3 (1)
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
@@ -163,7 +164,6 @@ void mp_hal_dupterm_tx_strn(const char *str, size_t len);
#endif
#define MICROPY_PORT_BUILTINS \
- { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
extern const struct _mp_obj_module_t mp_module_os;
diff --git a/windows/windows_mphal.c b/windows/windows_mphal.c
index 1dd3105d8..a73140e54 100644
--- a/windows/windows_mphal.c
+++ b/windows/windows_mphal.c
@@ -72,7 +72,7 @@ void mp_hal_stdio_mode_orig(void) {
// Previous versions of the mp_hal code would install a handler whenever Ctrl-C input is
// allowed and remove the handler again when it is not. That is not necessary though (1),
// and it might introduce problems (2) because console notifications are delivered to the
-// application in a seperate thread.
+// application in a separate thread.
// (1) mp_hal_set_interrupt_char effectively enables/disables processing of Ctrl-C via the
// ENABLE_PROCESSED_INPUT flag so in raw mode console_sighandler won't be called.
// (2) if mp_hal_set_interrupt_char would remove the handler while Ctrl-C was issued earlier,
diff --git a/zephyr/machine_pin.c b/zephyr/machine_pin.c
index f011f51fd..38971399c 100644
--- a/zephyr/machine_pin.c
+++ b/zephyr/machine_pin.c
@@ -117,7 +117,7 @@ STATIC mp_obj_t machine_pin_call(mp_obj_t self_in, size_t n_args, size_t n_kw, c
mp_arg_check_num(n_args, n_kw, 0, 1, false);
machine_pin_obj_t *self = self_in;
if (n_args == 0) {
- uint32_t pin_val;
+ u32_t pin_val;
(void)gpio_pin_read(self->port, self->pin, &pin_val);
return MP_OBJ_NEW_SMALL_INT(pin_val);
} else {
@@ -158,7 +158,7 @@ STATIC mp_uint_t machine_pin_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
switch (request) {
case MP_PIN_READ: {
- uint32_t pin_val;
+ u32_t pin_val;
gpio_pin_read(self->port, self->pin, &pin_val);
return pin_val;
}
diff --git a/zephyr/modusocket.c b/zephyr/modusocket.c
index 0a54ea576..cec0eec7c 100644
--- a/zephyr/modusocket.c
+++ b/zephyr/modusocket.c
@@ -587,7 +587,8 @@ STATIC mp_obj_t mod_getaddrinfo(size_t n_args, const mp_obj_t *args) {
// Raise error only if there's nothing to return, otherwise
// it may be IPv4 vs IPv6 differences.
- if (state.status != 0 && mp_obj_len(state.result) == 0) {
+ mp_int_t len = MP_OBJ_SMALL_INT_VALUE(mp_obj_len(state.result));
+ if (state.status != 0 && len == 0) {
mp_raise_OSError(state.status);
}
diff --git a/zephyr/modutime.c b/zephyr/modutime.c
index 378068bb3..0c268046a 100644
--- a/zephyr/modutime.c
+++ b/zephyr/modutime.c
@@ -36,7 +36,7 @@
#include "extmod/utime_mphal.h"
STATIC mp_obj_t mod_time_time(void) {
- /* The absense of FP support is deliberate. The Zephyr port uses
+ /* The absence of FP support is deliberate. The Zephyr port uses
* single precision floats so the fraction component will start to
* lose precision on devices with a long uptime.
*/
diff --git a/zephyr/mpconfigport.h b/zephyr/mpconfigport.h
index 98a033be4..2f2526779 100644
--- a/zephyr/mpconfigport.h
+++ b/zephyr/mpconfigport.h
@@ -80,6 +80,8 @@
#define MICROPY_COMP_CONST (0)
#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (0)
+#define MICROPY_PY_SYS_PLATFORM "zephyr"
+
#ifdef CONFIG_BOARD
#define MICROPY_HW_BOARD_NAME "zephyr-" CONFIG_BOARD
#else