summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ports_unix.yml2
-rw-r--r--.gitignore8
-rw-r--r--docs/pyboard/tutorial/lcd_skin.rst4
-rw-r--r--docs/reference/asm_thumb2_index.rst2
-rw-r--r--extmod/asyncio/core.py2
-rw-r--r--extmod/modtls_mbedtls.c2
-rw-r--r--extmod/modwebsocket.c28
-rw-r--r--extmod/vfs.c2
-rw-r--r--ports/esp32/machine_hw_spi.c8
-rw-r--r--ports/unix/Makefile25
-rw-r--r--ports/webassembly/asyncio/core.py2
-rw-r--r--ports/windows/msvc/paths.props2
-rw-r--r--py/builtinhelp.c2
-rw-r--r--py/builtinimport.c4
-rw-r--r--py/gc.c2
-rw-r--r--py/makemoduledefs.py16
-rw-r--r--py/misc.h12
-rw-r--r--py/mpconfig.h2
-rw-r--r--py/objexcept.c2
-rw-r--r--py/objmodule.c15
-rw-r--r--py/objmodule.h3
-rw-r--r--py/objstr.c2
-rw-r--r--py/py.mk2
-rw-r--r--py/repl.c7
-rw-r--r--tests/basics/async_await2.py2
-rw-r--r--tests/basics/async_for2.py2
-rw-r--r--tests/basics/async_with2.py2
-rw-r--r--tests/basics/boundmeth1.py2
-rw-r--r--tests/basics/builtin_range.py2
-rw-r--r--tests/basics/builtin_setattr.py2
-rw-r--r--tests/basics/class_bind_self.py2
-rw-r--r--tests/basics/del_attr.py2
-rw-r--r--tests/basics/del_global.py2
-rw-r--r--tests/basics/del_name.py2
-rw-r--r--tests/basics/frozenset_set.py2
-rw-r--r--tests/basics/fun_name.py2
-rw-r--r--tests/basics/gc1.py4
-rw-r--r--tests/basics/io_iobase.py2
-rw-r--r--tests/basics/list_pop.py2
-rw-r--r--tests/basics/module2.py2
-rw-r--r--tests/basics/parser.py2
-rw-r--r--tests/basics/python34.py2
-rw-r--r--tests/basics/syntaxerror.py4
-rw-r--r--tests/basics/sys_tracebacklimit.py2
-rw-r--r--tests/basics/tuple1.py2
-rw-r--r--tests/cpydiff/modules_struct_fewargs.py2
-rw-r--r--tests/cpydiff/modules_struct_manyargs.py2
-rw-r--r--tests/cpydiff/modules_struct_whitespace_in_format.py2
-rw-r--r--tests/cpydiff/types_float_implicit_conversion.py2
-rw-r--r--tests/extmod/asyncio_set_exception_handler.py2
-rw-r--r--tests/extmod/hashlib_md5.py3
-rw-r--r--tests/extmod/hashlib_sha1.py3
-rw-r--r--tests/extmod/hashlib_sha256.py3
-rw-r--r--tests/extmod/json_dump.py4
-rw-r--r--tests/extmod/json_dump_iobase.py2
-rw-r--r--tests/extmod/json_dump_separators.py6
-rw-r--r--tests/extmod/json_dumps_extra.py2
-rw-r--r--tests/extmod/json_dumps_separators.py2
-rw-r--r--tests/extmod/re_error.py2
-rw-r--r--tests/extmod/re_sub.py2
-rw-r--r--tests/extmod/websocket_basic.py27
-rw-r--r--tests/extmod/websocket_basic.py.exp9
-rw-r--r--tests/extmod/websocket_toobig.py28
-rw-r--r--tests/extmod/websocket_toobig.py.exp1
-rw-r--r--tests/float/string_format2.py4
-rw-r--r--tests/float/string_format_modulo.py2
-rw-r--r--tests/frozen/frozentest.mpybin196 -> 201 bytes
-rw-r--r--tests/frozen/frozentest.py2
-rw-r--r--tests/io/builtin_print_file.py2
-rw-r--r--tests/io/file_seek.py2
-rw-r--r--tests/micropython/decorator_error.py2
-rw-r--r--tests/micropython/heapalloc_traceback.py2
-rw-r--r--tests/misc/non_compliant.py6
-rw-r--r--tests/misc/non_compliant_lexer.py2
-rw-r--r--tests/misc/print_exception.py6
-rw-r--r--tests/ports/unix/extra_coverage.py2
-rw-r--r--tests/ports/unix/extra_coverage.py.exp2
77 files changed, 220 insertions, 120 deletions
diff --git a/.github/workflows/ports_unix.yml b/.github/workflows/ports_unix.yml
index d406a912a..deee7b265 100644
--- a/.github/workflows/ports_unix.yml
+++ b/.github/workflows/ports_unix.yml
@@ -232,7 +232,7 @@ jobs:
run: tests/run-tests.py --print-failures
macos:
- runs-on: macos-latest
+ runs-on: macos-26
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
diff --git a/.gitignore b/.gitignore
index b5010dfd1..56616426f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,11 @@ user.props
# MacOS desktop metadata files
.DS_Store
+
+# Created by ci.sh zephyr targets
+/.ccache
+/zephyrproject
+
+# Created by ci.sh esp8266 targets
+/xtensa-lx106-elf-standalone.tar.gz
+/xtensa-lx106-elf/
diff --git a/docs/pyboard/tutorial/lcd_skin.rst b/docs/pyboard/tutorial/lcd_skin.rst
index 4df004160..9d0ff473e 100644
--- a/docs/pyboard/tutorial/lcd_skin.rst
+++ b/docs/pyboard/tutorial/lcd_skin.rst
@@ -29,7 +29,7 @@ Make sure the LCD skin is attached to the pyboard as pictured at the top of this
>>> import pyb
>>> lcd = pyb.LCD('X')
>>> lcd.light(True)
- >>> lcd.write('Hello uPy!\n')
+ >>> lcd.write('Hello MPy!\n')
You can make a simple animation using the code::
@@ -38,7 +38,7 @@ You can make a simple animation using the code::
lcd.light(True)
for x in range(-80, 128):
lcd.fill(0)
- lcd.text('Hello uPy!', x, 10, 1)
+ lcd.text('Hello MPy!', x, 10, 1)
lcd.show()
pyb.delay(25)
diff --git a/docs/reference/asm_thumb2_index.rst b/docs/reference/asm_thumb2_index.rst
index ccf020148..97b3a8687 100644
--- a/docs/reference/asm_thumb2_index.rst
+++ b/docs/reference/asm_thumb2_index.rst
@@ -63,7 +63,7 @@ References
- :ref:`Assembler Tutorial <pyboard_tutorial_assembler>`
- `Wiki hints and tips
<http://wiki.micropython.org/platforms/boards/pyboard/assembler>`__
-- `uPy Inline Assembler source-code,
+- `MicroPython Inline Assembler source-code,
emitinlinethumb.c <https://github.com/micropython/micropython/blob/master/py/emitinlinethumb.c>`__
- `ARM Thumb2 Instruction Set Quick Reference
Card <http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf>`__
diff --git a/extmod/asyncio/core.py b/extmod/asyncio/core.py
index 5d46b4b80..7b70b43bc 100644
--- a/extmod/asyncio/core.py
+++ b/extmod/asyncio/core.py
@@ -50,7 +50,7 @@ class SingletonGenerator:
raise self.exc
-# Pause task execution for the given time (integer in milliseconds, uPy extension)
+# Pause task execution for the given time (integer in milliseconds, MicroPython extension)
# Use a SingletonGenerator to do it without allocating on the heap
def sleep_ms(t, sgen=SingletonGenerator()):
assert sgen.state is None
diff --git a/extmod/modtls_mbedtls.c b/extmod/modtls_mbedtls.c
index 586342573..e2f7254f7 100644
--- a/extmod/modtls_mbedtls.c
+++ b/extmod/modtls_mbedtls.c
@@ -304,7 +304,7 @@ static mp_obj_t ssl_context_make_new(const mp_obj_type_t *type_in, size_t n_args
psa_crypto_init();
#endif
- const byte seed[] = "upy";
+ const byte seed[] = "mpy";
int ret = mbedtls_ctr_drbg_seed(&self->ctr_drbg, mbedtls_entropy_func, &self->entropy, seed, sizeof(seed));
if (ret != 0) {
mbedtls_raise_error(ret);
diff --git a/extmod/modwebsocket.c b/extmod/modwebsocket.c
index d31d00160..6a35dc1db 100644
--- a/extmod/modwebsocket.c
+++ b/extmod/modwebsocket.c
@@ -76,6 +76,7 @@ static mp_obj_t websocket_make_new(const mp_obj_type_t *type, size_t n_args, siz
static mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) {
mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in);
+
const mp_stream_p_t *stream_p = mp_get_stream(self->sock);
while (1) {
if (self->to_recv != 0) {
@@ -93,9 +94,6 @@ static mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int
switch (self->state) {
case FRAME_HEADER: {
- // TODO: Split frame handling below is untested so far, so conservatively disable it
- assert(self->buf[0] & 0x80);
-
// "Control frames MAY be injected in the middle of a fragmented message."
// So, they must be processed before data frames (and not alter
// self->ws_flags)
@@ -120,14 +118,15 @@ static mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int
// Msg size is next 2 bytes
to_recv += 2;
} else if (sz == 127) {
- // Msg size is next 8 bytes
- assert(0);
+ // Msg size is next 8 bytes (unsupported, no way to recover)
+ mp_stream_close(self->sock);
+ *errcode = MP_EIO;
+ return MP_STREAM_ERROR;
}
if (self->buf[1] & 0x80) {
// Next 4 bytes is mask
to_recv += 4;
}
-
self->buf_pos = 0;
self->to_recv = to_recv;
self->msg_sz = sz; // May be overridden by FRAME_OPT
@@ -144,11 +143,13 @@ static mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int
}
case FRAME_OPT: {
- if ((self->buf_pos & 3) == 2) {
- // First two bytes are message length
+ if (self->buf_pos & 2) { // to_recv was 2 or 6
+ assert(self->buf_pos == 2 || self->buf_pos == 6);
+ // First two bytes are message length. Technically the size must be at least 126 per RFC6455
+ // but MicroPython skips checking that.
self->msg_sz = (self->buf[0] << 8) | self->buf[1];
}
- if (self->buf_pos >= 4) {
+ if (self->buf_pos & 4) {
// Last 4 bytes is mask
memcpy(self->mask, self->buf + self->buf_pos - 4, 4);
}
@@ -218,9 +219,16 @@ static mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int
static mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
mp_obj_websocket_t *self = MP_OBJ_TO_PTR(self_in);
- assert(size < 0x10000);
+ if (size >= 0x10000) {
+ *errcode = MP_ENOBUFS;
+ return MP_STREAM_ERROR;
+ }
byte header[4] = {0x80 | (self->opts & FRAME_OPCODE_MASK)};
int hdr_sz;
+ // "Note that in all cases, the minimal number of bytes MUST be used to
+ // encode the length, for example, the length of a 124-byte-long string
+ // can't be encoded as the sequence 126, 0, 124."
+ // -- https://www.rfc-editor.org/rfc/rfc6455.html
if (size < 126) {
header[1] = size;
hdr_sz = 2;
diff --git a/extmod/vfs.c b/extmod/vfs.c
index aebf5ed29..d2a7af5de 100644
--- a/extmod/vfs.c
+++ b/extmod/vfs.c
@@ -96,7 +96,7 @@ mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out) {
return MP_STATE_VM(vfs_cur);
}
-// Version of mp_vfs_lookup_path that takes and returns uPy string objects.
+// Version of mp_vfs_lookup_path that takes and returns MicroPython string objects.
static mp_vfs_mount_t *lookup_path(mp_obj_t path_in, mp_obj_t *path_out) {
const char *path = mp_obj_str_get_str(path_in);
const char *p_out;
diff --git a/ports/esp32/machine_hw_spi.c b/ports/esp32/machine_hw_spi.c
index 6eb83fc09..dcf8b3942 100644
--- a/ports/esp32/machine_hw_spi.c
+++ b/ports/esp32/machine_hw_spi.c
@@ -38,10 +38,10 @@
#include "soc/spi_pins.h"
// SPI mappings by device, naming used by IDF old/new
-// upython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3 | ESP32C6
-// ----------+-----------+-----------+---------+---------+---------
-// SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2 | SPI2
-// SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err | err
+// MicroPython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3 | ESP32C6
+// ------------+-----------+-----------+---------+---------+---------
+// SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2 | SPI2
+// SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err | err
// Number of available hardware SPI peripherals.
#if SOC_SPI_PERIPH_NUM > 2
diff --git a/ports/unix/Makefile b/ports/unix/Makefile
index 7df4c6f79..81751bf0f 100644
--- a/ports/unix/Makefile
+++ b/ports/unix/Makefile
@@ -26,6 +26,9 @@ FROZEN_MANIFEST ?= variants/manifest.py
# This should be configured by the mpconfigvariant.mk
PROG ?= micropython
+# For use in test rules below
+ABS_PROG = $(abspath $(BUILD)/$(PROG))
+
# qstr definitions (must come before including py.mk)
QSTR_DEFS += qstrdefsport.h
QSTR_GLOBAL_DEPENDENCIES += $(VARIANT_DIR)/mpconfigvariant.h
@@ -257,16 +260,13 @@ include $(TOP)/py/mkrules.mk
.PHONY: test test_full_no_native test_full test//% test/% test-failures print-failures clean-failures
test: $(BUILD)/$(PROG) $(TOP)/tests/run-tests.py
- $(eval DIRNAME=ports/$(notdir $(CURDIR)))
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(BUILD)/$(PROG) ./run-tests.py
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=$(ABS_PROG) ./run-tests.py
test//%: $(BUILD)/$(PROG) $(TOP)/tests/run-tests.py
- $(eval DIRNAME=ports/$(notdir $(CURDIR)))
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(BUILD)/$(PROG) ./run-tests.py -i "$*"
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=$(ABS_PROG) ./run-tests.py -i "$*"
test-failures: $(BUILD)/$(PROG) $(TOP)/tests/run-tests.py
- $(eval DIRNAME=ports/$(notdir $(CURDIR)))
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(BUILD)/$(PROG) ./run-tests.py --run-failures
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=$(ABS_PROG) ./run-tests.py --run-failures
print-failures:
cd $(TOP)/tests && ./run-tests.py --print-failures
@@ -275,18 +275,15 @@ clean-failures:
cd $(TOP)/tests && ./run-tests.py --clean-failures
test/%: $(BUILD)/$(PROG) $(TOP)/tests/run-tests.py
- $(eval DIRNAME=ports/$(notdir $(CURDIR)))
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(BUILD)/$(PROG) ./run-tests.py -d "$*"
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=$(ABS_PROG) ./run-tests.py -d "$*"
test_full_no_native: $(BUILD)/$(PROG) $(TOP)/tests/run-tests.py test
- $(eval DIRNAME=ports/$(notdir $(CURDIR)))
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(BUILD)/$(PROG) ./run-tests.py --via-mpy $(RUN_TESTS_MPY_CROSS_FLAGS)
- cat $(TOP)/tests/basics/0prelim.py | ./$(BUILD)/$(PROG) | grep -q 'abc'
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=$(ABS_PROG) ./run-tests.py --via-mpy $(RUN_TESTS_MPY_CROSS_FLAGS)
+ cat $(TOP)/tests/basics/0prelim.py | $(ABS_PROG) | grep -q 'abc'
test_full: $(BUILD)/$(PROG) $(TOP)/tests/run-tests.py test_full_no_native
- $(eval DIRNAME=ports/$(notdir $(CURDIR)))
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(BUILD)/$(PROG) ./run-tests.py --emit native
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(BUILD)/$(PROG) ./run-tests.py --via-mpy $(RUN_TESTS_MPY_CROSS_FLAGS) --emit native
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=$(ABS_PROG) ./run-tests.py --emit native
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=$(ABS_PROG) ./run-tests.py --via-mpy $(RUN_TESTS_MPY_CROSS_FLAGS) --emit native
test_gcov: test_full
gcov -o $(BUILD)/py $(TOP)/py/*.c
diff --git a/ports/webassembly/asyncio/core.py b/ports/webassembly/asyncio/core.py
index 9d07bd7b8..eeffa253b 100644
--- a/ports/webassembly/asyncio/core.py
+++ b/ports/webassembly/asyncio/core.py
@@ -47,7 +47,7 @@ class SingletonGenerator:
raise self.exc
-# Pause task execution for the given time (integer in milliseconds, uPy extension)
+# Pause task execution for the given time (integer in milliseconds, MicroPython extension)
# Use a SingletonGenerator to do it without allocating on the heap
def sleep_ms(t, sgen=SingletonGenerator()):
assert sgen.state is None
diff --git a/ports/windows/msvc/paths.props b/ports/windows/msvc/paths.props
index 767772a1a..a88182f4c 100644
--- a/ports/windows/msvc/paths.props
+++ b/ports/windows/msvc/paths.props
@@ -31,7 +31,7 @@
<PyVariantDir Condition="'$(PyVariantDir)' == ''">$(PyWinDir)variants\$(PyVariant)\</PyVariantDir>
<PyTargetDir Condition="'$(PyTargetDir)' == ''">$(PyBuildDir)</PyTargetDir>
- <!-- All include directories needed for uPy -->
+ <!-- All include directories needed for MicroPython -->
<PyIncDirs>$(PyIncDirs);$(PyBaseDir);$(PyWinDir);$(PyBuildDir);$(PyWinDir)msvc;$(PyVariantDir)</PyIncDirs>
<!-- Within PyBuildDir different subdirectories are used based on configuration and platform.
diff --git a/py/builtinhelp.c b/py/builtinhelp.c
index c08c2e3b6..dc4fe582f 100644
--- a/py/builtinhelp.c
+++ b/py/builtinhelp.c
@@ -79,7 +79,9 @@ static void mp_help_print_modules(void) {
mp_obj_t list = mp_obj_new_list(0, NULL);
mp_help_add_from_map(list, &mp_builtin_module_map);
+ #if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
mp_help_add_from_map(list, &mp_builtin_extensible_module_map);
+ #endif
#if MICROPY_MODULE_FROZEN
extern const char mp_frozen_names[];
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 57b5c14e8..ff894f69d 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -403,6 +403,7 @@ static mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
// all the locations in sys.path.
stat = stat_top_level(level_mod_name, &path);
+ #if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
// If filesystem failed, now try and see if it matches an extensible
// built-in module.
if (stat == MP_IMPORT_STAT_NO_EXIST) {
@@ -411,6 +412,7 @@ static mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
return module_obj;
}
}
+ #endif
} else {
DEBUG_printf("Searching for sub-module\n");
@@ -646,11 +648,13 @@ mp_obj_t mp_builtin___import___default(size_t n_args, const mp_obj_t *args) {
if (module_obj != MP_OBJ_NULL) {
return module_obj;
}
+ #if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
// Now try as an extensible built-in (e.g. `time`).
module_obj = mp_module_get_builtin(module_name_qstr, true);
if (module_obj != MP_OBJ_NULL) {
return module_obj;
}
+ #endif
// Couldn't find the module, so fail
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
diff --git a/py/gc.c b/py/gc.c
index de66137f5..aa9f1e38b 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -1245,7 +1245,7 @@ void gc_dump_alloc_table(const mp_print_t *print) {
break;
}
*/
- /* this prints the uPy object type of the head block */
+ /* this prints the MicroPython object type of the head block */
case AT_HEAD: {
void **ptr = (void **)(area->gc_pool_start + bl * BYTES_PER_BLOCK);
if (*ptr == &mp_type_tuple) {
diff --git a/py/makemoduledefs.py b/py/makemoduledefs.py
index 1488db5c9..c8fdc21f6 100644
--- a/py/makemoduledefs.py
+++ b/py/makemoduledefs.py
@@ -85,19 +85,25 @@ def generate_module_table_header(modules):
)
)
+ # There should always be at least one module (__main__ in runtime.c)
+ assert mod_defs
+
print("\n#define MICROPY_REGISTERED_MODULES \\")
for mod_def in sorted(mod_defs):
print(" {mod_def} \\".format(mod_def=mod_def))
-
print("// MICROPY_REGISTERED_MODULES")
- print("\n#define MICROPY_REGISTERED_EXTENSIBLE_MODULES \\")
+ # There are not necessarily any extensible modules (e.g., bare-arm or minimal x86)
+ print("\n#define MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES ", len(extensible_mod_defs))
- for mod_def in sorted(extensible_mod_defs):
- print(" {mod_def} \\".format(mod_def=mod_def))
+ if extensible_mod_defs:
+ print("\n#define MICROPY_REGISTERED_EXTENSIBLE_MODULES \\")
+
+ for mod_def in sorted(extensible_mod_defs):
+ print(" {mod_def} \\".format(mod_def=mod_def))
- print("// MICROPY_REGISTERED_EXTENSIBLE_MODULES")
+ print("// MICROPY_REGISTERED_EXTENSIBLE_MODULES")
def generate_module_delegations(delegations):
diff --git a/py/misc.h b/py/misc.h
index ee33f84e8..67248ac2f 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -67,7 +67,14 @@ typedef unsigned int uint;
#define MP_STRINGIFY(x) MP_STRINGIFY_HELPER(x)
// Static assertion macro
+#if __cplusplus
+#define MP_STATIC_ASSERT(cond) static_assert((cond), #cond)
+#elif __GNUC__ >= 5 || __STDC_VERSION__ >= 201112L
+#define MP_STATIC_ASSERT(cond) _Static_assert((cond), #cond)
+#else
#define MP_STATIC_ASSERT(cond) ((void)sizeof(char[1 - 2 * !(cond)]))
+#endif
+
// In C++ things like comparing extern const pointers are not constant-expressions so cannot be used
// in MP_STATIC_ASSERT. Note that not all possible compiler versions will reject this. Some gcc versions
// do, others only with -Werror=vla, msvc always does.
@@ -76,7 +83,10 @@ typedef unsigned int uint;
#if defined(_MSC_VER) || defined(__cplusplus)
#define MP_STATIC_ASSERT_NONCONSTEXPR(cond) ((void)1)
#else
-#define MP_STATIC_ASSERT_NONCONSTEXPR(cond) MP_STATIC_ASSERT(cond)
+#if __clang__
+#pragma GCC diagnostic ignored "-Wgnu-folding-constant"
+#endif
+#define MP_STATIC_ASSERT_NONCONSTEXPR(cond) ((void)sizeof(char[1 - 2 * !(cond)]))
#endif
// Round-up integer division
diff --git a/py/mpconfig.h b/py/mpconfig.h
index c25401b8c..6da872c56 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -2099,7 +2099,7 @@ typedef time_t mp_timestamp_t;
/*****************************************************************************/
/* Miscellaneous settings */
-// All uPy objects in ROM must be aligned on at least a 4 byte boundary
+// All MicroPython objects in ROM must be aligned on at least a 4 byte boundary
// so that the small-int/qstr/pointer distinction can be made. For machines
// that don't do this (eg 16-bit CPU), define the following macro to something
// like __attribute__((aligned(4))).
diff --git a/py/objexcept.c b/py/objexcept.c
index 5bf4e672b..df91c32b1 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -272,7 +272,7 @@ void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
// We allow 'exc.__traceback__ = None' assignment as low-level
// optimization of pre-allocating exception instance and raising
// it repeatedly - this avoids memory allocation during raise.
- // However, uPy will keep adding traceback entries to such
+ // However, MicroPython will keep adding traceback entries to such
// exception instance, so before throwing it, traceback should
// be cleared like above.
self->traceback_len = 0;
diff --git a/py/objmodule.c b/py/objmodule.c
index 5ee2f7dc8..2ffa7847f 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -152,11 +152,13 @@ static const mp_rom_map_elem_t mp_builtin_module_table[] = {
};
MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table);
+#if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
static const mp_rom_map_elem_t mp_builtin_extensible_module_table[] = {
// built-in modules declared with MP_REGISTER_EXTENSIBLE_MODULE()
MICROPY_REGISTERED_EXTENSIBLE_MODULES
};
MP_DEFINE_CONST_MAP(mp_builtin_extensible_module_map, mp_builtin_extensible_module_table);
+#endif
#if MICROPY_MODULE_ATTR_DELEGATION && defined(MICROPY_MODULE_DELEGATIONS)
typedef struct _mp_module_delegation_entry_t {
@@ -173,7 +175,13 @@ static const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] =
// Attempts to find (and initialise) a built-in, otherwise returns
// MP_OBJ_NULL.
mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
- mp_map_elem_t *elem = mp_map_lookup((mp_map_t *)(extensible ? &mp_builtin_extensible_module_map : &mp_builtin_module_map), MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP);
+ #if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
+ const mp_map_t *map = extensible ? &mp_builtin_extensible_module_map : &mp_builtin_module_map;
+ #else
+ const mp_map_t *map = &mp_builtin_module_map;
+ #endif
+ mp_map_elem_t *elem = mp_map_lookup((mp_map_t *)map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP);
+
if (!elem) {
#if MICROPY_PY_SYS
// Special case for sys, which isn't extensible but can always be
@@ -183,6 +191,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
}
#endif
+ #if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
if (extensible) {
// At this point we've already tried non-extensible built-ins, the
// filesystem, and now extensible built-ins. No match, so fail
@@ -203,7 +212,9 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
if (module_name_str[0] != 'u') {
return MP_OBJ_NULL;
}
- elem = mp_map_lookup((mp_map_t *)&mp_builtin_extensible_module_map, MP_OBJ_NEW_QSTR(qstr_from_strn(module_name_str + 1, module_name_len - 1)), MP_MAP_LOOKUP);
+ elem = mp_map_lookup((mp_map_t *)&mp_builtin_extensible_module_map, MP_OBJ_NEW_QSTR(qstr_find_strn(module_name_str + 1, module_name_len - 1)), MP_MAP_LOOKUP);
+ #endif
+
if (!elem) {
return MP_OBJ_NULL;
}
diff --git a/py/objmodule.h b/py/objmodule.h
index 8b14cd9fc..78e4da3ca 100644
--- a/py/objmodule.h
+++ b/py/objmodule.h
@@ -35,7 +35,10 @@
#endif
extern const mp_map_t mp_builtin_module_map;
+
+#if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
extern const mp_map_t mp_builtin_extensible_module_map;
+#endif
mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible);
diff --git a/py/objstr.c b/py/objstr.c
index c81fc682f..df543041a 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -1304,7 +1304,7 @@ static vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
}
case '\0': // No explicit format type implies 'd'
- case 'n': // I don't think we support locales in uPy so use 'd'
+ case 'n': // I don't think we support locales in MicroPython so use 'd'
case 'd':
mp_print_mp_int(&print, arg, 10, 'a', flags, fill, width, 0);
continue;
diff --git a/py/py.mk b/py/py.mk
index e352d8979..e7716a1ad 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -252,7 +252,7 @@ $(HEADER_BUILD)/compressed.data.h: $(HEADER_BUILD)/compressed.collected
$(Q)$(PYTHON) $(PY_SRC)/makecompresseddata.py $< > $@
# build a list of registered modules for py/objmodule.c.
-$(HEADER_BUILD)/moduledefs.h: $(HEADER_BUILD)/moduledefs.collected
+$(HEADER_BUILD)/moduledefs.h: $(HEADER_BUILD)/moduledefs.collected $(PY_SRC)/makemoduledefs.py
@$(ECHO) "GEN $@"
$(Q)$(PYTHON) $(PY_SRC)/makemoduledefs.py $< > $@
diff --git a/py/repl.c b/py/repl.c
index b0ccfa383..87cb50d47 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -162,8 +162,11 @@ static bool test_qstr(mp_obj_t obj, qstr name) {
return dest[0] != MP_OBJ_NULL;
} else {
// try builtin module
- return mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(name), MP_MAP_LOOKUP) ||
- mp_map_lookup((mp_map_t *)&mp_builtin_extensible_module_map, MP_OBJ_NEW_QSTR(name), MP_MAP_LOOKUP);
+ return mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(name), MP_MAP_LOOKUP)
+ #if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
+ || mp_map_lookup((mp_map_t *)&mp_builtin_extensible_module_map, MP_OBJ_NEW_QSTR(name), MP_MAP_LOOKUP)
+ #endif
+ ;
}
}
diff --git a/tests/basics/async_await2.py b/tests/basics/async_await2.py
index 1e3164df9..7c1c85bfa 100644
--- a/tests/basics/async_await2.py
+++ b/tests/basics/async_await2.py
@@ -2,7 +2,7 @@
import sys
if sys.implementation.name == 'micropython':
- # uPy allows normal generators to be awaitables
+ # MicroPython allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types
diff --git a/tests/basics/async_for2.py b/tests/basics/async_for2.py
index aad23a3e5..530ff390c 100644
--- a/tests/basics/async_for2.py
+++ b/tests/basics/async_for2.py
@@ -2,7 +2,7 @@
import sys
if sys.implementation.name == 'micropython':
- # uPy allows normal generators to be awaitables
+ # MicroPython allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types
diff --git a/tests/basics/async_with2.py b/tests/basics/async_with2.py
index 44421ae91..bcdbfa906 100644
--- a/tests/basics/async_with2.py
+++ b/tests/basics/async_with2.py
@@ -2,7 +2,7 @@
import sys
if sys.implementation.name == 'micropython':
- # uPy allows normal generators to be awaitables
+ # MicroPython allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types
diff --git a/tests/basics/boundmeth1.py b/tests/basics/boundmeth1.py
index fe1b45468..9f08d9bbb 100644
--- a/tests/basics/boundmeth1.py
+++ b/tests/basics/boundmeth1.py
@@ -1,6 +1,6 @@
# tests basics of bound methods
-# uPy and CPython differ when printing a bound method, so just print the type
+# MicroPython and CPython differ when printing a bound method, so just print the type
print(type(repr([].append)))
diff --git a/tests/basics/builtin_range.py b/tests/basics/builtin_range.py
index 728679bc9..9608a8163 100644
--- a/tests/basics/builtin_range.py
+++ b/tests/basics/builtin_range.py
@@ -54,7 +54,7 @@ print(range(1, 100, 5)[15:5:3])
print(range(1, 100, -5)[5:15:-3])
print(range(1, 100, -5)[15:5:3])
-# for this case uPy gives a different stop value but the listed elements are still correct
+# for this case MicroPython gives a different stop value but the listed elements are still correct
print(list(range(7, -2, -4)[2:-2:]))
# zero step
diff --git a/tests/basics/builtin_setattr.py b/tests/basics/builtin_setattr.py
index e4acb14ca..2c9a452c3 100644
--- a/tests/basics/builtin_setattr.py
+++ b/tests/basics/builtin_setattr.py
@@ -21,5 +21,5 @@ except TypeError:
try:
setattr(int, 'to_bytes', 1)
except (AttributeError, TypeError):
- # uPy raises AttributeError, CPython raises TypeError
+ # MicroPython raises AttributeError, CPython raises TypeError
print('AttributeError/TypeError')
diff --git a/tests/basics/class_bind_self.py b/tests/basics/class_bind_self.py
index 813f87644..8bece902c 100644
--- a/tests/basics/class_bind_self.py
+++ b/tests/basics/class_bind_self.py
@@ -52,7 +52,7 @@ print(C.f7(12))
print(C.f8(13))
print(C.f9(14))
-# not working in uPy
+# not working in MicroPython
#class C(list):
# # this acts like a method and binds self
# f1 = list.extend
diff --git a/tests/basics/del_attr.py b/tests/basics/del_attr.py
index 8487b97e3..90a8a5a6f 100644
--- a/tests/basics/del_attr.py
+++ b/tests/basics/del_attr.py
@@ -35,5 +35,5 @@ except AttributeError:
try:
del int.to_bytes
except (AttributeError, TypeError):
- # uPy raises AttributeError, CPython raises TypeError
+ # MicroPython raises AttributeError, CPython raises TypeError
print('AttributeError/TypeError')
diff --git a/tests/basics/del_global.py b/tests/basics/del_global.py
index d740357b0..e1aa074b9 100644
--- a/tests/basics/del_global.py
+++ b/tests/basics/del_global.py
@@ -14,7 +14,7 @@ except NameError:
try:
do_del()
except: # NameError:
- # FIXME uPy returns KeyError for this
+ # FIXME MicroPython returns KeyError for this
print("NameError")
# delete globals using a list
diff --git a/tests/basics/del_name.py b/tests/basics/del_name.py
index c92be54d3..8393b2df9 100644
--- a/tests/basics/del_name.py
+++ b/tests/basics/del_name.py
@@ -10,7 +10,7 @@ except NameError:
try:
del x
except: # NameError:
- # FIXME uPy returns KeyError for this
+ # FIXME MicroPython returns KeyError for this
print("NameError")
class C:
diff --git a/tests/basics/frozenset_set.py b/tests/basics/frozenset_set.py
index 3bf456acf..2b3c68326 100644
--- a/tests/basics/frozenset_set.py
+++ b/tests/basics/frozenset_set.py
@@ -8,5 +8,5 @@ except NameError:
# "Instances of set are compared to instances of frozenset based on their
# members. For example:"
print(set('abc') == frozenset('abc'))
-# This doesn't work in uPy
+# This doesn't work in MicroPython
#print(set('abc') in set([frozenset('abc')]))
diff --git a/tests/basics/fun_name.py b/tests/basics/fun_name.py
index b2642280a..8aac35eea 100644
--- a/tests/basics/fun_name.py
+++ b/tests/basics/fun_name.py
@@ -16,7 +16,7 @@ except AttributeError:
print('SKIP')
raise SystemExit
-# __name__ of a bound native method is not implemented in uPy
+# __name__ of a bound native method is not implemented in MicroPython
# the test here is to make sure it doesn't crash
try:
str((1).to_bytes.__name__)
diff --git a/tests/basics/gc1.py b/tests/basics/gc1.py
index 332bf9744..dff9538b1 100644
--- a/tests/basics/gc1.py
+++ b/tests/basics/gc1.py
@@ -15,13 +15,13 @@ print(gc.isenabled())
gc.collect()
if hasattr(gc, 'mem_free'):
- # uPy has these extra functions
+ # MicroPython has these extra functions
# just test they execute and return an int
assert type(gc.mem_free()) is int
assert type(gc.mem_alloc()) is int
if hasattr(gc, 'threshold'):
- # uPy has this extra function
+ # MicroPython has this extra function
# check execution and returns
assert(gc.threshold(1) is None)
assert(gc.threshold() == 0)
diff --git a/tests/basics/io_iobase.py b/tests/basics/io_iobase.py
index c01ca6a50..de7e4a0b0 100644
--- a/tests/basics/io_iobase.py
+++ b/tests/basics/io_iobase.py
@@ -9,7 +9,7 @@ except (AttributeError, ImportError):
class MyIO(io.IOBase):
def write(self, buf):
- # CPython and uPy pass in different types for buf (str vs bytearray)
+ # CPython and MicroPython pass in different types for buf (str vs bytearray)
print('write', len(buf))
return len(buf)
diff --git a/tests/basics/list_pop.py b/tests/basics/list_pop.py
index 87ed456f8..58bcdd91e 100644
--- a/tests/basics/list_pop.py
+++ b/tests/basics/list_pop.py
@@ -10,7 +10,7 @@ except IndexError:
else:
raise AssertionError("No IndexError raised")
-# popping such that list storage shrinks (tests implementation detail of uPy)
+# popping such that list storage shrinks (tests implementation detail of MicroPython)
l = list(range(20))
for i in range(len(l)):
l.pop()
diff --git a/tests/basics/module2.py b/tests/basics/module2.py
index a13560157..d1dc18930 100644
--- a/tests/basics/module2.py
+++ b/tests/basics/module2.py
@@ -1,4 +1,4 @@
-# uPy behaviour only: builtin modules are read-only
+# MicroPython behaviour only: builtin modules are read-only
import sys
try:
sys.x = 1
diff --git a/tests/basics/parser.py b/tests/basics/parser.py
index 626b67ad7..6ae5f05ba 100644
--- a/tests/basics/parser.py
+++ b/tests/basics/parser.py
@@ -7,7 +7,7 @@ except NameError:
raise SystemExit
# completely empty string
-# uPy and CPy differ for this case
+# MPy and CPy differ for this case
#try:
# compile("", "stdin", "single")
#except SyntaxError:
diff --git a/tests/basics/python34.py b/tests/basics/python34.py
index 922234d22..3071b55ef 100644
--- a/tests/basics/python34.py
+++ b/tests/basics/python34.py
@@ -28,7 +28,7 @@ test_syntax("() = []") # can't assign to empty tuple (in 3.6 we can)
test_syntax("del ()") # can't delete empty tuple (in 3.6 we can)
# from basics/sys1.py
-# uPy prints version 3.4
+# MicroPython prints version 3.4
import sys
print(sys.version[:3])
print(sys.version_info[0], sys.version_info[1])
diff --git a/tests/basics/syntaxerror.py b/tests/basics/syntaxerror.py
index c0702cb24..7b6ef9b75 100644
--- a/tests/basics/syntaxerror.py
+++ b/tests/basics/syntaxerror.py
@@ -86,7 +86,7 @@ test_syntax("yield")
test_syntax("nonlocal a")
test_syntax("await 1")
-# error on uPy, warning on CPy
+# error on MPy, warning on CPy
#test_syntax("def f():\n a = 1\n global a")
# default except must be last
@@ -98,7 +98,7 @@ test_syntax("f(1=2)")
# non-keyword after keyword
test_syntax("f(a=1, 2)")
-# doesn't error on uPy but should
+# doesn't error on MPy but should
#test_syntax("f(1, i for i in i)")
# all elements of dict/set must be pairs or singles
diff --git a/tests/basics/sys_tracebacklimit.py b/tests/basics/sys_tracebacklimit.py
index 3ae372b8d..6f575fde6 100644
--- a/tests/basics/sys_tracebacklimit.py
+++ b/tests/basics/sys_tracebacklimit.py
@@ -30,7 +30,7 @@ def print_exc(e):
if l.startswith(" File "):
l = l.split('"')
print(l[0], l[2])
- # uPy and CPy tracebacks differ in that CPy prints a source line for
+ # MPy and CPy tracebacks differ in that CPy prints a source line for
# each traceback entry. In this case, we know that offending line
# has 4-space indent, so filter it out.
elif not l.startswith(" "):
diff --git a/tests/basics/tuple1.py b/tests/basics/tuple1.py
index 72bb3f01b..70ae07189 100644
--- a/tests/basics/tuple1.py
+++ b/tests/basics/tuple1.py
@@ -17,7 +17,7 @@ print(x + (10, 100, 10000))
x += (10, 11, 12)
print(x)
-# construction of tuple from large iterator (tests implementation detail of uPy)
+# construction of tuple from large iterator (tests implementation detail of MicroPython)
print(tuple(range(20)))
# unsupported unary operation
diff --git a/tests/cpydiff/modules_struct_fewargs.py b/tests/cpydiff/modules_struct_fewargs.py
index 49b2a3213..f6346a679 100644
--- a/tests/cpydiff/modules_struct_fewargs.py
+++ b/tests/cpydiff/modules_struct_fewargs.py
@@ -1,6 +1,6 @@
"""
categories: Modules,struct
-description: Struct pack with too few args, not checked by uPy
+description: Struct pack with too few args, not checked by MicroPython
cause: Unknown
workaround: Unknown
"""
diff --git a/tests/cpydiff/modules_struct_manyargs.py b/tests/cpydiff/modules_struct_manyargs.py
index e3b78930f..b2ea93b6c 100644
--- a/tests/cpydiff/modules_struct_manyargs.py
+++ b/tests/cpydiff/modules_struct_manyargs.py
@@ -1,6 +1,6 @@
"""
categories: Modules,struct
-description: Struct pack with too many args, not checked by uPy
+description: Struct pack with too many args, not checked by MicroPython
cause: Unknown
workaround: Unknown
"""
diff --git a/tests/cpydiff/modules_struct_whitespace_in_format.py b/tests/cpydiff/modules_struct_whitespace_in_format.py
index a7a1d2fac..8b609425e 100644
--- a/tests/cpydiff/modules_struct_whitespace_in_format.py
+++ b/tests/cpydiff/modules_struct_whitespace_in_format.py
@@ -1,6 +1,6 @@
"""
categories: Modules,struct
-description: Struct pack with whitespace in format, whitespace ignored by CPython, error on uPy
+description: Struct pack with whitespace in format, whitespace ignored by CPython, error on MicroPython
cause: MicroPython is optimised for code size.
workaround: Don't use spaces in format strings.
"""
diff --git a/tests/cpydiff/types_float_implicit_conversion.py b/tests/cpydiff/types_float_implicit_conversion.py
index 3726839fa..764c9e4e6 100644
--- a/tests/cpydiff/types_float_implicit_conversion.py
+++ b/tests/cpydiff/types_float_implicit_conversion.py
@@ -1,6 +1,6 @@
"""
categories: Types,float
-description: uPy allows implicit conversion of objects in maths operations while CPython does not.
+description: MicroPython allows implicit conversion of objects in maths operations while CPython does not.
cause: Unknown
workaround: Objects should be wrapped in ``float(obj)`` for compatibility with CPython.
"""
diff --git a/tests/extmod/asyncio_set_exception_handler.py b/tests/extmod/asyncio_set_exception_handler.py
index 5935f0f4e..0ac4a6242 100644
--- a/tests/extmod/asyncio_set_exception_handler.py
+++ b/tests/extmod/asyncio_set_exception_handler.py
@@ -12,7 +12,7 @@ def custom_handler(loop, context):
async def task(i):
- # Raise with 2 args so exception prints the same in uPy and CPython
+ # Raise with 2 args so exception prints the same in MicroPython and CPython
raise ValueError(i, i + 1)
diff --git a/tests/extmod/hashlib_md5.py b/tests/extmod/hashlib_md5.py
index 5f925fc97..ebbe9155e 100644
--- a/tests/extmod/hashlib_md5.py
+++ b/tests/extmod/hashlib_md5.py
@@ -1,8 +1,7 @@
try:
import hashlib
except ImportError:
- # This is neither uPy, nor cPy, so must be uPy with
- # hashlib module disabled.
+ # MicroPython with hashlib module disabled.
print("SKIP")
raise SystemExit
diff --git a/tests/extmod/hashlib_sha1.py b/tests/extmod/hashlib_sha1.py
index af23033a5..46ffb73fc 100644
--- a/tests/extmod/hashlib_sha1.py
+++ b/tests/extmod/hashlib_sha1.py
@@ -1,8 +1,7 @@
try:
import hashlib
except ImportError:
- # This is neither uPy, nor cPy, so must be uPy with
- # hashlib module disabled.
+ # MicroPython with hashlib module disabled.
print("SKIP")
raise SystemExit
diff --git a/tests/extmod/hashlib_sha256.py b/tests/extmod/hashlib_sha256.py
index f0d07e148..ffa0922a1 100644
--- a/tests/extmod/hashlib_sha256.py
+++ b/tests/extmod/hashlib_sha256.py
@@ -1,8 +1,7 @@
try:
import hashlib
except ImportError:
- # This is neither uPy, nor cPy, so must be uPy with
- # hashlib module disabled.
+ # MicroPython with hashlib module disabled.
print("SKIP")
raise SystemExit
diff --git a/tests/extmod/json_dump.py b/tests/extmod/json_dump.py
index 897d33cc8..0beb4f5f8 100644
--- a/tests/extmod/json_dump.py
+++ b/tests/extmod/json_dump.py
@@ -16,11 +16,11 @@ print(s.getvalue())
# dump to a small-int not allowed
try:
json.dump(123, 1)
-except (AttributeError, OSError): # CPython and uPy have different errors
+except (AttributeError, OSError): # CPython and MicroPython have different errors
print("Exception")
# dump to an object not allowed
try:
json.dump(123, {})
-except (AttributeError, OSError): # CPython and uPy have different errors
+except (AttributeError, OSError): # CPython and MicroPython have different errors
print("Exception")
diff --git a/tests/extmod/json_dump_iobase.py b/tests/extmod/json_dump_iobase.py
index 94d317b87..81105e36d 100644
--- a/tests/extmod/json_dump_iobase.py
+++ b/tests/extmod/json_dump_iobase.py
@@ -18,7 +18,7 @@ class S(io.IOBase):
def write(self, buf):
if type(buf) == bytearray:
- # uPy passes a bytearray, CPython passes a str
+ # MicroPython passes a bytearray, CPython passes a str
buf = str(buf, "ascii")
self.buf += buf
return len(buf)
diff --git a/tests/extmod/json_dump_separators.py b/tests/extmod/json_dump_separators.py
index 4f8e56dce..ce3929482 100644
--- a/tests/extmod/json_dump_separators.py
+++ b/tests/extmod/json_dump_separators.py
@@ -25,20 +25,20 @@ for sep in [
# dump to a small-int not allowed
try:
json.dump(123, 1, separators=sep)
- except (AttributeError, OSError): # CPython and uPy have different errors
+ except (AttributeError, OSError): # CPython and MicroPython have different errors
print("Exception")
# dump to an object not allowed
try:
json.dump(123, {}, separators=sep)
- except (AttributeError, OSError): # CPython and uPy have different errors
+ except (AttributeError, OSError): # CPython and MicroPython have different errors
print("Exception")
try:
s = StringIO()
json.dump(False, s, separators={"a": 1})
-except (TypeError, ValueError): # CPython and uPy have different errors
+except (TypeError, ValueError): # CPython and MicroPython have different errors
print("Exception")
# invalid separator types
diff --git a/tests/extmod/json_dumps_extra.py b/tests/extmod/json_dumps_extra.py
index 9074416a9..9faf8eefa 100644
--- a/tests/extmod/json_dumps_extra.py
+++ b/tests/extmod/json_dumps_extra.py
@@ -1,4 +1,4 @@
-# test uPy json behaviour that's not valid in CPy
+# test MicroPython json behaviour that's not valid in CPython
try:
import json
diff --git a/tests/extmod/json_dumps_separators.py b/tests/extmod/json_dumps_separators.py
index a3a9ec308..0a95f489a 100644
--- a/tests/extmod/json_dumps_separators.py
+++ b/tests/extmod/json_dumps_separators.py
@@ -39,7 +39,7 @@ for sep in [
try:
json.dumps(False, separators={"a": 1})
-except (TypeError, ValueError): # CPython and uPy have different errors
+except (TypeError, ValueError): # CPython and MicroPython have different errors
print("Exception")
# invalid separator types
diff --git a/tests/extmod/re_error.py b/tests/extmod/re_error.py
index f61d09132..bd678c9d2 100644
--- a/tests/extmod/re_error.py
+++ b/tests/extmod/re_error.py
@@ -11,7 +11,7 @@ def test_re(r):
try:
re.compile(r)
print("OK")
- except: # uPy and CPy use different errors, so just ignore the type
+ except: # MPy and CPy use different errors, so just ignore the type
print("Error")
diff --git a/tests/extmod/re_sub.py b/tests/extmod/re_sub.py
index ecaa66d83..95ba1d70d 100644
--- a/tests/extmod/re_sub.py
+++ b/tests/extmod/re_sub.py
@@ -61,7 +61,7 @@ try:
except:
print("invalid group")
-# invalid group with very large number (to test overflow in uPy)
+# invalid group with very large number (to test overflow in MicroPython)
try:
re.sub("(a)", "b\\199999999999999999999999999999999999999", "a")
except:
diff --git a/tests/extmod/websocket_basic.py b/tests/extmod/websocket_basic.py
index 133457784..6ebd65d65 100644
--- a/tests/extmod/websocket_basic.py
+++ b/tests/extmod/websocket_basic.py
@@ -13,6 +13,13 @@ def ws_read(msg, sz):
return ws.read(sz)
+# put raw data in the stream and do a series of websocket read
+def ws_readn(msg, *args):
+ ws = websocket.websocket(io.BytesIO(msg))
+ for sz in args:
+ yield ws.read(sz)
+
+
# do a websocket write and then return the raw data from the stream
def ws_write(msg, sz):
s = io.BytesIO()
@@ -24,18 +31,28 @@ def ws_write(msg, sz):
# basic frame
print(ws_read(b"\x81\x04ping", 4))
-print(ws_read(b"\x80\x04ping", 4)) # FRAME_CONT
print(ws_write(b"pong", 6))
-# split frames are not supported
-# print(ws_read(b"\x01\x04ping", 4))
+# split frames and irregular size reads
+for s in ws_readn(b"\x01\x04ping\x00\x04Ping\x80\x04PING", 6, 4, 2, 2):
+ print(s)
# extended payloads
print(ws_read(b"\x81~\x00\x80" + b"ping" * 32, 128))
print(ws_write(b"pong" * 32, 132))
-# mask (returned data will be 'mask' ^ 'mask')
-print(ws_read(b"\x81\x84maskmask", 4))
+# 64-bit payload size, unsupported by MicroPython implementation. Framing is lost.
+msg = b"\x81\x7f\x00\x00\x00\x00\x00\x00\x00\x80" + b"ping" * 32
+ws = websocket.websocket(io.BytesIO(msg))
+try:
+ print(ws.read(1))
+except OSError as e:
+ print("ioctl: EIO:", e.errno == errno.EIO)
+
+# mask (returned data will be 'maskmask' ^ 'maskMASK')
+print(ws_read(b"\x81\x88maskmaskMASK", 8))
+# mask w/2-byte payload len (returned data will be 'maskmask' ^ 'maskMASK')
+print(ws_read(b"\x81\xfe\x00\x08maskmaskMASK", 8))
# close control frame
s = io.BytesIO(b"\x88\x00") # FRAME_CLOSE
diff --git a/tests/extmod/websocket_basic.py.exp b/tests/extmod/websocket_basic.py.exp
index 152aae836..e4164ac69 100644
--- a/tests/extmod/websocket_basic.py.exp
+++ b/tests/extmod/websocket_basic.py.exp
@@ -1,9 +1,14 @@
b'ping'
-b'ping'
b'\x81\x04pong'
+b'pingPi'
+b'ngPI'
+b'NG'
+b''
b'pingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingpingping'
b'\x81~\x00\x80pongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpongpong'
-b'\x00\x00\x00\x00'
+ioctl: EIO: True
+b'\x00\x00\x00\x00 '
+b'\x00\x00\x00\x00 '
b''
b'\x88\x00'
b'ping'
diff --git a/tests/extmod/websocket_toobig.py b/tests/extmod/websocket_toobig.py
new file mode 100644
index 000000000..f4c5a74bb
--- /dev/null
+++ b/tests/extmod/websocket_toobig.py
@@ -0,0 +1,28 @@
+try:
+ import io
+ import errno
+ import websocket
+except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+try:
+ buf = "x" * 65536
+except MemoryError:
+ print("SKIP")
+ raise SystemExit
+
+
+# do a websocket write and then return the raw data from the stream
+def ws_write(msg, sz):
+ s = io.BytesIO()
+ ws = websocket.websocket(s)
+ ws.write(msg)
+ s.seek(0)
+ return s.read(sz)
+
+
+try:
+ print(ws_write(buf, 1))
+except OSError as e:
+ print("ioctl: ENOBUFS:", e.errno == errno.ENOBUFS)
diff --git a/tests/extmod/websocket_toobig.py.exp b/tests/extmod/websocket_toobig.py.exp
new file mode 100644
index 000000000..3bbd95282
--- /dev/null
+++ b/tests/extmod/websocket_toobig.py.exp
@@ -0,0 +1 @@
+ioctl: ENOBUFS: True
diff --git a/tests/float/string_format2.py b/tests/float/string_format2.py
index 7a36f4d2f..cdea4c119 100644
--- a/tests/float/string_format2.py
+++ b/tests/float/string_format2.py
@@ -144,7 +144,7 @@ if full_tests:
for alignment in ("", "<", ">", "=", "^"):
for fill in ("", " ", "0", "@"):
for sign in ("", "+", "-", " "):
- # An empty precision defaults to 6, but when uPy is
+ # An empty precision defaults to 6, but when MicroPython is
# configured to use a float, we can only use a
# precision of 6 with numbers less than 10 and still
# get results that compare to CPython (which uses
@@ -164,7 +164,7 @@ if full_tests:
for alignment in ("", "<", ">", "=", "^"):
for fill in ("", " ", "0", "@"):
for sign in ("", "+", "-", " "):
- # An empty precision defaults to 6, but when uPy is
+ # An empty precision defaults to 6, but when MicroPython is
# configured to use a float, we can only use a
# precision of 6 with numbers less than 10 and still
# get results that compare to CPython (which uses
diff --git a/tests/float/string_format_modulo.py b/tests/float/string_format_modulo.py
index 3c206b739..553146433 100644
--- a/tests/float/string_format_modulo.py
+++ b/tests/float/string_format_modulo.py
@@ -6,7 +6,7 @@ print("%i" % 1.0)
print("%u" % 1.0)
# these 3 have different behaviour in Python 3.x versions
-# uPy raises a TypeError, following Python 3.5 (earlier versions don't)
+# MicroPython raises a TypeError, following Python 3.5 (earlier versions don't)
# print("%x" % 18.0)
# print("%o" % 18.0)
# print("%X" % 18.0)
diff --git a/tests/frozen/frozentest.mpy b/tests/frozen/frozentest.mpy
index 99581617a..ccdf5e1a9 100644
--- a/tests/frozen/frozentest.mpy
+++ b/tests/frozen/frozentest.mpy
Binary files differ
diff --git a/tests/frozen/frozentest.py b/tests/frozen/frozentest.py
index 78cdd60bf..74bdfb3b2 100644
--- a/tests/frozen/frozentest.py
+++ b/tests/frozen/frozentest.py
@@ -1,4 +1,4 @@
-print("uPy")
+print("interned")
print("a long string that is not interned")
print("a string that has unicode αβγ chars")
print(b"bytes 1234\x01")
diff --git a/tests/io/builtin_print_file.py b/tests/io/builtin_print_file.py
index 822356a6c..e00f58635 100644
--- a/tests/io/builtin_print_file.py
+++ b/tests/io/builtin_print_file.py
@@ -13,5 +13,5 @@ print("test", file=sys.stdout)
try:
print(file=1)
-except (AttributeError, OSError): # CPython and uPy differ in error message
+except (AttributeError, OSError): # CPython and MicroPython differ in error message
print("Error")
diff --git a/tests/io/file_seek.py b/tests/io/file_seek.py
index 3990df840..b9f959378 100644
--- a/tests/io/file_seek.py
+++ b/tests/io/file_seek.py
@@ -30,5 +30,5 @@ f.close()
try:
f.seek(1)
except (OSError, ValueError):
- # CPy raises ValueError, uPy raises OSError
+ # CPy raises ValueError, MPy raises OSError
print("OSError or ValueError")
diff --git a/tests/micropython/decorator_error.py b/tests/micropython/decorator_error.py
index 94772ac1e..b5eae65b2 100644
--- a/tests/micropython/decorator_error.py
+++ b/tests/micropython/decorator_error.py
@@ -1,4 +1,4 @@
-# test syntax errors for uPy-specific decorators
+# test syntax errors for MicroPython-specific decorators
def test_syntax(code):
diff --git a/tests/micropython/heapalloc_traceback.py b/tests/micropython/heapalloc_traceback.py
index 5ded8c5f0..1743d4956 100644
--- a/tests/micropython/heapalloc_traceback.py
+++ b/tests/micropython/heapalloc_traceback.py
@@ -34,7 +34,7 @@ test()
buf = io.StringIO()
sys.print_exception(global_exc, buf)
for l in buf.getvalue().split("\n"):
- # uPy on pyboard prints <stdin> as file, so remove filename.
+ # MicroPython on pyboard prints <stdin> as file, so remove filename.
if l.startswith(" File "):
l = l.split('"')
print(l[0], l[2])
diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py
index dd62f6325..54ad2960e 100644
--- a/tests/misc/non_compliant.py
+++ b/tests/misc/non_compliant.py
@@ -39,7 +39,7 @@ try:
except NotImplementedError:
print("NotImplementedError")
-# uPy raises TypeError, should be ValueError
+# MicroPython raises TypeError, should be ValueError
try:
"%c" % b"\x01\x02"
except (TypeError, ValueError):
@@ -99,10 +99,10 @@ try:
except NotImplementedError:
print("NotImplementedError")
-# struct pack with too many args, not checked by uPy
+# struct pack with too many args, not checked by MicroPython
print(struct.pack("bb", 1, 2, 3))
-# struct pack with too few args, not checked by uPy
+# struct pack with too few args, not checked by MicroPython
print(struct.pack("bb", 1))
# array slice assignment with unsupported RHS
diff --git a/tests/misc/non_compliant_lexer.py b/tests/misc/non_compliant_lexer.py
index e1c21f3d7..04c605953 100644
--- a/tests/misc/non_compliant_lexer.py
+++ b/tests/misc/non_compliant_lexer.py
@@ -11,7 +11,7 @@ def test(code):
print("NotImplementedError")
-# uPy requires spaces between literal numbers and keywords, CPy doesn't
+# MPy requires spaces between literal numbers and keywords, CPy doesn't
try:
eval("1and 0")
except SyntaxError:
diff --git a/tests/misc/print_exception.py b/tests/misc/print_exception.py
index d41478360..fdf5711c5 100644
--- a/tests/misc/print_exception.py
+++ b/tests/misc/print_exception.py
@@ -20,11 +20,11 @@ def print_exc(e):
print_exception(e, buf)
s = buf.getvalue()
for l in s.split("\n"):
- # uPy on pyboard prints <stdin> as file, so remove filename.
+ # MPy on pyboard prints <stdin> as file, so remove filename.
if l.startswith(" File "):
l = l.split('"')
print(l[0], l[2])
- # uPy and CPy tracebacks differ in that CPy prints a source line for
+ # MPy and CPy tracebacks differ in that CPy prints a source line for
# each traceback entry. In this case, we know that offending line
# has 4-space indent, so filter it out.
elif not l.startswith(" "):
@@ -89,7 +89,7 @@ try:
except Exception as e:
print_exc(e)
-# Test non-stream object passed as output object, only valid for uPy
+# Test non-stream object passed as output object, only valid for MicroPython
if hasattr(sys, "print_exception"):
try:
sys.print_exception(Exception, 1)
diff --git a/tests/ports/unix/extra_coverage.py b/tests/ports/unix/extra_coverage.py
index 493d02cde..2087e7ea2 100644
--- a/tests/ports/unix/extra_coverage.py
+++ b/tests/ports/unix/extra_coverage.py
@@ -128,7 +128,7 @@ from frzqstr import returns_NULL
print(returns_NULL())
-# test for freeze_mpy
+# test for freeze_mpy (importing prints several lines)
import frozentest
print(frozentest.__file__)
diff --git a/tests/ports/unix/extra_coverage.py.exp b/tests/ports/unix/extra_coverage.py.exp
index 5b6e1f3f0..d11e5ee6f 100644
--- a/tests/ports/unix/extra_coverage.py.exp
+++ b/tests/ports/unix/extra_coverage.py.exp
@@ -250,7 +250,7 @@ b'\x00\xff'
frzmpy4 1
frzmpy4 2
NULL
-uPy
+interned
a long string that is not interned
a string that has unicode αβγ chars
b'bytes 1234\x01'