mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
all: Replace legacy name with MicroPython and MPy as applicable.
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
With the aim of getting consistency, and removing the need to learn an additional term, replace uses of uPy/uPython with MPy/MicroPython. Rule of thumb was to use "MPy" abbreviation where "CPy" is used nearby, but the full word MicroPython otherwise. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
committed by
Damien George
parent
fb2b638ba0
commit
3ec8b9a77c
@@ -29,7 +29,7 @@ Make sure the LCD skin is attached to the pyboard as pictured at the top of this
|
|||||||
>>> import pyb
|
>>> import pyb
|
||||||
>>> lcd = pyb.LCD('X')
|
>>> lcd = pyb.LCD('X')
|
||||||
>>> lcd.light(True)
|
>>> lcd.light(True)
|
||||||
>>> lcd.write('Hello uPy!\n')
|
>>> lcd.write('Hello MPy!\n')
|
||||||
|
|
||||||
You can make a simple animation using the code::
|
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)
|
lcd.light(True)
|
||||||
for x in range(-80, 128):
|
for x in range(-80, 128):
|
||||||
lcd.fill(0)
|
lcd.fill(0)
|
||||||
lcd.text('Hello uPy!', x, 10, 1)
|
lcd.text('Hello MPy!', x, 10, 1)
|
||||||
lcd.show()
|
lcd.show()
|
||||||
pyb.delay(25)
|
pyb.delay(25)
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ References
|
|||||||
- :ref:`Assembler Tutorial <pyboard_tutorial_assembler>`
|
- :ref:`Assembler Tutorial <pyboard_tutorial_assembler>`
|
||||||
- `Wiki hints and tips
|
- `Wiki hints and tips
|
||||||
<http://wiki.micropython.org/platforms/boards/pyboard/assembler>`__
|
<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>`__
|
emitinlinethumb.c <https://github.com/micropython/micropython/blob/master/py/emitinlinethumb.c>`__
|
||||||
- `ARM Thumb2 Instruction Set Quick Reference
|
- `ARM Thumb2 Instruction Set Quick Reference
|
||||||
Card <http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf>`__
|
Card <http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf>`__
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class SingletonGenerator:
|
|||||||
raise self.exc
|
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
|
# Use a SingletonGenerator to do it without allocating on the heap
|
||||||
def sleep_ms(t, sgen=SingletonGenerator()):
|
def sleep_ms(t, sgen=SingletonGenerator()):
|
||||||
assert sgen.state is None
|
assert sgen.state is None
|
||||||
|
|||||||
@@ -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();
|
psa_crypto_init();
|
||||||
#endif
|
#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));
|
int ret = mbedtls_ctr_drbg_seed(&self->ctr_drbg, mbedtls_entropy_func, &self->entropy, seed, sizeof(seed));
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
mbedtls_raise_error(ret);
|
mbedtls_raise_error(ret);
|
||||||
|
|||||||
@@ -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);
|
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) {
|
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 *path = mp_obj_str_get_str(path_in);
|
||||||
const char *p_out;
|
const char *p_out;
|
||||||
|
|||||||
@@ -38,10 +38,10 @@
|
|||||||
#include "soc/spi_pins.h"
|
#include "soc/spi_pins.h"
|
||||||
|
|
||||||
// SPI mappings by device, naming used by IDF old/new
|
// SPI mappings by device, naming used by IDF old/new
|
||||||
// upython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3 | ESP32C6
|
// MicroPython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3 | ESP32C6
|
||||||
// ----------+-----------+-----------+---------+---------+---------
|
// ------------+-----------+-----------+---------+---------+---------
|
||||||
// SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2 | SPI2
|
// SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2 | SPI2
|
||||||
// SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err | err
|
// SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err | err
|
||||||
|
|
||||||
// Number of available hardware SPI peripherals.
|
// Number of available hardware SPI peripherals.
|
||||||
#if SOC_SPI_PERIPH_NUM > 2
|
#if SOC_SPI_PERIPH_NUM > 2
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class SingletonGenerator:
|
|||||||
raise self.exc
|
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
|
# Use a SingletonGenerator to do it without allocating on the heap
|
||||||
def sleep_ms(t, sgen=SingletonGenerator()):
|
def sleep_ms(t, sgen=SingletonGenerator()):
|
||||||
assert sgen.state is None
|
assert sgen.state is None
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
<PyVariantDir Condition="'$(PyVariantDir)' == ''">$(PyWinDir)variants\$(PyVariant)\</PyVariantDir>
|
<PyVariantDir Condition="'$(PyVariantDir)' == ''">$(PyWinDir)variants\$(PyVariant)\</PyVariantDir>
|
||||||
<PyTargetDir Condition="'$(PyTargetDir)' == ''">$(PyBuildDir)</PyTargetDir>
|
<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>
|
<PyIncDirs>$(PyIncDirs);$(PyBaseDir);$(PyWinDir);$(PyBuildDir);$(PyWinDir)msvc;$(PyVariantDir)</PyIncDirs>
|
||||||
|
|
||||||
<!-- Within PyBuildDir different subdirectories are used based on configuration and platform.
|
<!-- Within PyBuildDir different subdirectories are used based on configuration and platform.
|
||||||
|
|||||||
2
py/gc.c
2
py/gc.c
@@ -1245,7 +1245,7 @@ void gc_dump_alloc_table(const mp_print_t *print) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* this prints the uPy object type of the head block */
|
/* this prints the MicroPython object type of the head block */
|
||||||
case AT_HEAD: {
|
case AT_HEAD: {
|
||||||
void **ptr = (void **)(area->gc_pool_start + bl * BYTES_PER_BLOCK);
|
void **ptr = (void **)(area->gc_pool_start + bl * BYTES_PER_BLOCK);
|
||||||
if (*ptr == &mp_type_tuple) {
|
if (*ptr == &mp_type_tuple) {
|
||||||
|
|||||||
@@ -2099,7 +2099,7 @@ typedef time_t mp_timestamp_t;
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Miscellaneous settings */
|
/* 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
|
// 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
|
// that don't do this (eg 16-bit CPU), define the following macro to something
|
||||||
// like __attribute__((aligned(4))).
|
// like __attribute__((aligned(4))).
|
||||||
|
|||||||
@@ -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
|
// We allow 'exc.__traceback__ = None' assignment as low-level
|
||||||
// optimization of pre-allocating exception instance and raising
|
// optimization of pre-allocating exception instance and raising
|
||||||
// it repeatedly - this avoids memory allocation during raise.
|
// 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
|
// exception instance, so before throwing it, traceback should
|
||||||
// be cleared like above.
|
// be cleared like above.
|
||||||
self->traceback_len = 0;
|
self->traceback_len = 0;
|
||||||
|
|||||||
@@ -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 '\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':
|
case 'd':
|
||||||
mp_print_mp_int(&print, arg, 10, 'a', flags, fill, width, 0);
|
mp_print_mp_int(&print, arg, 10, 'a', flags, fill, width, 0);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
if sys.implementation.name == 'micropython':
|
if sys.implementation.name == 'micropython':
|
||||||
# uPy allows normal generators to be awaitables
|
# MicroPython allows normal generators to be awaitables
|
||||||
coroutine = lambda f: f
|
coroutine = lambda f: f
|
||||||
else:
|
else:
|
||||||
import types
|
import types
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
if sys.implementation.name == 'micropython':
|
if sys.implementation.name == 'micropython':
|
||||||
# uPy allows normal generators to be awaitables
|
# MicroPython allows normal generators to be awaitables
|
||||||
coroutine = lambda f: f
|
coroutine = lambda f: f
|
||||||
else:
|
else:
|
||||||
import types
|
import types
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
if sys.implementation.name == 'micropython':
|
if sys.implementation.name == 'micropython':
|
||||||
# uPy allows normal generators to be awaitables
|
# MicroPython allows normal generators to be awaitables
|
||||||
coroutine = lambda f: f
|
coroutine = lambda f: f
|
||||||
else:
|
else:
|
||||||
import types
|
import types
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# tests basics of bound methods
|
# 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)))
|
print(type(repr([].append)))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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)[5:15:-3])
|
||||||
print(range(1, 100, -5)[15:5: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:]))
|
print(list(range(7, -2, -4)[2:-2:]))
|
||||||
|
|
||||||
# zero step
|
# zero step
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ except TypeError:
|
|||||||
try:
|
try:
|
||||||
setattr(int, 'to_bytes', 1)
|
setattr(int, 'to_bytes', 1)
|
||||||
except (AttributeError, TypeError):
|
except (AttributeError, TypeError):
|
||||||
# uPy raises AttributeError, CPython raises TypeError
|
# MicroPython raises AttributeError, CPython raises TypeError
|
||||||
print('AttributeError/TypeError')
|
print('AttributeError/TypeError')
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ print(C.f7(12))
|
|||||||
print(C.f8(13))
|
print(C.f8(13))
|
||||||
print(C.f9(14))
|
print(C.f9(14))
|
||||||
|
|
||||||
# not working in uPy
|
# not working in MicroPython
|
||||||
#class C(list):
|
#class C(list):
|
||||||
# # this acts like a method and binds self
|
# # this acts like a method and binds self
|
||||||
# f1 = list.extend
|
# f1 = list.extend
|
||||||
|
|||||||
@@ -35,5 +35,5 @@ except AttributeError:
|
|||||||
try:
|
try:
|
||||||
del int.to_bytes
|
del int.to_bytes
|
||||||
except (AttributeError, TypeError):
|
except (AttributeError, TypeError):
|
||||||
# uPy raises AttributeError, CPython raises TypeError
|
# MicroPython raises AttributeError, CPython raises TypeError
|
||||||
print('AttributeError/TypeError')
|
print('AttributeError/TypeError')
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ except NameError:
|
|||||||
try:
|
try:
|
||||||
do_del()
|
do_del()
|
||||||
except: # NameError:
|
except: # NameError:
|
||||||
# FIXME uPy returns KeyError for this
|
# FIXME MicroPython returns KeyError for this
|
||||||
print("NameError")
|
print("NameError")
|
||||||
|
|
||||||
# delete globals using a list
|
# delete globals using a list
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ except NameError:
|
|||||||
try:
|
try:
|
||||||
del x
|
del x
|
||||||
except: # NameError:
|
except: # NameError:
|
||||||
# FIXME uPy returns KeyError for this
|
# FIXME MicroPython returns KeyError for this
|
||||||
print("NameError")
|
print("NameError")
|
||||||
|
|
||||||
class C:
|
class C:
|
||||||
|
|||||||
@@ -8,5 +8,5 @@ except NameError:
|
|||||||
# "Instances of set are compared to instances of frozenset based on their
|
# "Instances of set are compared to instances of frozenset based on their
|
||||||
# members. For example:"
|
# members. For example:"
|
||||||
print(set('abc') == frozenset('abc'))
|
print(set('abc') == frozenset('abc'))
|
||||||
# This doesn't work in uPy
|
# This doesn't work in MicroPython
|
||||||
#print(set('abc') in set([frozenset('abc')]))
|
#print(set('abc') in set([frozenset('abc')]))
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ except AttributeError:
|
|||||||
print('SKIP')
|
print('SKIP')
|
||||||
raise SystemExit
|
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
|
# the test here is to make sure it doesn't crash
|
||||||
try:
|
try:
|
||||||
str((1).to_bytes.__name__)
|
str((1).to_bytes.__name__)
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ print(gc.isenabled())
|
|||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
if hasattr(gc, 'mem_free'):
|
if hasattr(gc, 'mem_free'):
|
||||||
# uPy has these extra functions
|
# MicroPython has these extra functions
|
||||||
# just test they execute and return an int
|
# just test they execute and return an int
|
||||||
assert type(gc.mem_free()) is int
|
assert type(gc.mem_free()) is int
|
||||||
assert type(gc.mem_alloc()) is int
|
assert type(gc.mem_alloc()) is int
|
||||||
|
|
||||||
if hasattr(gc, 'threshold'):
|
if hasattr(gc, 'threshold'):
|
||||||
# uPy has this extra function
|
# MicroPython has this extra function
|
||||||
# check execution and returns
|
# check execution and returns
|
||||||
assert(gc.threshold(1) is None)
|
assert(gc.threshold(1) is None)
|
||||||
assert(gc.threshold() == 0)
|
assert(gc.threshold() == 0)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ except (AttributeError, ImportError):
|
|||||||
|
|
||||||
class MyIO(io.IOBase):
|
class MyIO(io.IOBase):
|
||||||
def write(self, buf):
|
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))
|
print('write', len(buf))
|
||||||
return len(buf)
|
return len(buf)
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ except IndexError:
|
|||||||
else:
|
else:
|
||||||
raise AssertionError("No IndexError raised")
|
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))
|
l = list(range(20))
|
||||||
for i in range(len(l)):
|
for i in range(len(l)):
|
||||||
l.pop()
|
l.pop()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# uPy behaviour only: builtin modules are read-only
|
# MicroPython behaviour only: builtin modules are read-only
|
||||||
import sys
|
import sys
|
||||||
try:
|
try:
|
||||||
sys.x = 1
|
sys.x = 1
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ except NameError:
|
|||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# completely empty string
|
# completely empty string
|
||||||
# uPy and CPy differ for this case
|
# MPy and CPy differ for this case
|
||||||
#try:
|
#try:
|
||||||
# compile("", "stdin", "single")
|
# compile("", "stdin", "single")
|
||||||
#except SyntaxError:
|
#except SyntaxError:
|
||||||
|
|||||||
@@ -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)
|
test_syntax("del ()") # can't delete empty tuple (in 3.6 we can)
|
||||||
|
|
||||||
# from basics/sys1.py
|
# from basics/sys1.py
|
||||||
# uPy prints version 3.4
|
# MicroPython prints version 3.4
|
||||||
import sys
|
import sys
|
||||||
print(sys.version[:3])
|
print(sys.version[:3])
|
||||||
print(sys.version_info[0], sys.version_info[1])
|
print(sys.version_info[0], sys.version_info[1])
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ test_syntax("yield")
|
|||||||
test_syntax("nonlocal a")
|
test_syntax("nonlocal a")
|
||||||
test_syntax("await 1")
|
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")
|
#test_syntax("def f():\n a = 1\n global a")
|
||||||
|
|
||||||
# default except must be last
|
# default except must be last
|
||||||
@@ -98,7 +98,7 @@ test_syntax("f(1=2)")
|
|||||||
# non-keyword after keyword
|
# non-keyword after keyword
|
||||||
test_syntax("f(a=1, 2)")
|
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)")
|
#test_syntax("f(1, i for i in i)")
|
||||||
|
|
||||||
# all elements of dict/set must be pairs or singles
|
# all elements of dict/set must be pairs or singles
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ def print_exc(e):
|
|||||||
if l.startswith(" File "):
|
if l.startswith(" File "):
|
||||||
l = l.split('"')
|
l = l.split('"')
|
||||||
print(l[0], l[2])
|
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
|
# each traceback entry. In this case, we know that offending line
|
||||||
# has 4-space indent, so filter it out.
|
# has 4-space indent, so filter it out.
|
||||||
elif not l.startswith(" "):
|
elif not l.startswith(" "):
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ print(x + (10, 100, 10000))
|
|||||||
x += (10, 11, 12)
|
x += (10, 11, 12)
|
||||||
print(x)
|
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)))
|
print(tuple(range(20)))
|
||||||
|
|
||||||
# unsupported unary operation
|
# unsupported unary operation
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
categories: Modules,struct
|
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
|
cause: Unknown
|
||||||
workaround: Unknown
|
workaround: Unknown
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
categories: Modules,struct
|
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
|
cause: Unknown
|
||||||
workaround: Unknown
|
workaround: Unknown
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
categories: Modules,struct
|
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.
|
cause: MicroPython is optimised for code size.
|
||||||
workaround: Don't use spaces in format strings.
|
workaround: Don't use spaces in format strings.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
categories: Types,float
|
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
|
cause: Unknown
|
||||||
workaround: Objects should be wrapped in ``float(obj)`` for compatibility with CPython.
|
workaround: Objects should be wrapped in ``float(obj)`` for compatibility with CPython.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ def custom_handler(loop, context):
|
|||||||
|
|
||||||
|
|
||||||
async def task(i):
|
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)
|
raise ValueError(i, i + 1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
try:
|
try:
|
||||||
import hashlib
|
import hashlib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# This is neither uPy, nor cPy, so must be uPy with
|
# MicroPython with hashlib module disabled.
|
||||||
# hashlib module disabled.
|
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
try:
|
try:
|
||||||
import hashlib
|
import hashlib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# This is neither uPy, nor cPy, so must be uPy with
|
# MicroPython with hashlib module disabled.
|
||||||
# hashlib module disabled.
|
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
try:
|
try:
|
||||||
import hashlib
|
import hashlib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# This is neither uPy, nor cPy, so must be uPy with
|
# MicroPython with hashlib module disabled.
|
||||||
# hashlib module disabled.
|
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ print(s.getvalue())
|
|||||||
# dump to a small-int not allowed
|
# dump to a small-int not allowed
|
||||||
try:
|
try:
|
||||||
json.dump(123, 1)
|
json.dump(123, 1)
|
||||||
except (AttributeError, OSError): # CPython and uPy have different errors
|
except (AttributeError, OSError): # CPython and MicroPython have different errors
|
||||||
print("Exception")
|
print("Exception")
|
||||||
|
|
||||||
# dump to an object not allowed
|
# dump to an object not allowed
|
||||||
try:
|
try:
|
||||||
json.dump(123, {})
|
json.dump(123, {})
|
||||||
except (AttributeError, OSError): # CPython and uPy have different errors
|
except (AttributeError, OSError): # CPython and MicroPython have different errors
|
||||||
print("Exception")
|
print("Exception")
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class S(io.IOBase):
|
|||||||
|
|
||||||
def write(self, buf):
|
def write(self, buf):
|
||||||
if type(buf) == bytearray:
|
if type(buf) == bytearray:
|
||||||
# uPy passes a bytearray, CPython passes a str
|
# MicroPython passes a bytearray, CPython passes a str
|
||||||
buf = str(buf, "ascii")
|
buf = str(buf, "ascii")
|
||||||
self.buf += buf
|
self.buf += buf
|
||||||
return len(buf)
|
return len(buf)
|
||||||
|
|||||||
@@ -25,20 +25,20 @@ for sep in [
|
|||||||
# dump to a small-int not allowed
|
# dump to a small-int not allowed
|
||||||
try:
|
try:
|
||||||
json.dump(123, 1, separators=sep)
|
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")
|
print("Exception")
|
||||||
|
|
||||||
# dump to an object not allowed
|
# dump to an object not allowed
|
||||||
try:
|
try:
|
||||||
json.dump(123, {}, separators=sep)
|
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")
|
print("Exception")
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
s = StringIO()
|
s = StringIO()
|
||||||
json.dump(False, s, separators={"a": 1})
|
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")
|
print("Exception")
|
||||||
|
|
||||||
# invalid separator types
|
# invalid separator types
|
||||||
|
|||||||
@@ -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:
|
try:
|
||||||
import json
|
import json
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ for sep in [
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
json.dumps(False, separators={"a": 1})
|
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")
|
print("Exception")
|
||||||
|
|
||||||
# invalid separator types
|
# invalid separator types
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def test_re(r):
|
|||||||
try:
|
try:
|
||||||
re.compile(r)
|
re.compile(r)
|
||||||
print("OK")
|
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")
|
print("Error")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
print("invalid group")
|
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:
|
try:
|
||||||
re.sub("(a)", "b\\199999999999999999999999999999999999999", "a")
|
re.sub("(a)", "b\\199999999999999999999999999999999999999", "a")
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ if full_tests:
|
|||||||
for alignment in ("", "<", ">", "=", "^"):
|
for alignment in ("", "<", ">", "=", "^"):
|
||||||
for fill in ("", " ", "0", "@"):
|
for fill in ("", " ", "0", "@"):
|
||||||
for sign in ("", "+", "-", " "):
|
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
|
# configured to use a float, we can only use a
|
||||||
# precision of 6 with numbers less than 10 and still
|
# precision of 6 with numbers less than 10 and still
|
||||||
# get results that compare to CPython (which uses
|
# get results that compare to CPython (which uses
|
||||||
@@ -164,7 +164,7 @@ if full_tests:
|
|||||||
for alignment in ("", "<", ">", "=", "^"):
|
for alignment in ("", "<", ">", "=", "^"):
|
||||||
for fill in ("", " ", "0", "@"):
|
for fill in ("", " ", "0", "@"):
|
||||||
for sign in ("", "+", "-", " "):
|
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
|
# configured to use a float, we can only use a
|
||||||
# precision of 6 with numbers less than 10 and still
|
# precision of 6 with numbers less than 10 and still
|
||||||
# get results that compare to CPython (which uses
|
# get results that compare to CPython (which uses
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ print("%i" % 1.0)
|
|||||||
print("%u" % 1.0)
|
print("%u" % 1.0)
|
||||||
|
|
||||||
# these 3 have different behaviour in Python 3.x versions
|
# 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("%x" % 18.0)
|
||||||
# print("%o" % 18.0)
|
# print("%o" % 18.0)
|
||||||
# print("%X" % 18.0)
|
# print("%X" % 18.0)
|
||||||
|
|||||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
print("uPy")
|
print("interned")
|
||||||
print("a long string that is not interned")
|
print("a long string that is not interned")
|
||||||
print("a string that has unicode αβγ chars")
|
print("a string that has unicode αβγ chars")
|
||||||
print(b"bytes 1234\x01")
|
print(b"bytes 1234\x01")
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ print("test", file=sys.stdout)
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
print(file=1)
|
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")
|
print("Error")
|
||||||
|
|||||||
@@ -30,5 +30,5 @@ f.close()
|
|||||||
try:
|
try:
|
||||||
f.seek(1)
|
f.seek(1)
|
||||||
except (OSError, ValueError):
|
except (OSError, ValueError):
|
||||||
# CPy raises ValueError, uPy raises OSError
|
# CPy raises ValueError, MPy raises OSError
|
||||||
print("OSError or ValueError")
|
print("OSError or ValueError")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# test syntax errors for uPy-specific decorators
|
# test syntax errors for MicroPython-specific decorators
|
||||||
|
|
||||||
|
|
||||||
def test_syntax(code):
|
def test_syntax(code):
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ test()
|
|||||||
buf = io.StringIO()
|
buf = io.StringIO()
|
||||||
sys.print_exception(global_exc, buf)
|
sys.print_exception(global_exc, buf)
|
||||||
for l in buf.getvalue().split("\n"):
|
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 "):
|
if l.startswith(" File "):
|
||||||
l = l.split('"')
|
l = l.split('"')
|
||||||
print(l[0], l[2])
|
print(l[0], l[2])
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ try:
|
|||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
print("NotImplementedError")
|
print("NotImplementedError")
|
||||||
|
|
||||||
# uPy raises TypeError, should be ValueError
|
# MicroPython raises TypeError, should be ValueError
|
||||||
try:
|
try:
|
||||||
"%c" % b"\x01\x02"
|
"%c" % b"\x01\x02"
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
@@ -99,10 +99,10 @@ try:
|
|||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
print("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))
|
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))
|
print(struct.pack("bb", 1))
|
||||||
|
|
||||||
# array slice assignment with unsupported RHS
|
# array slice assignment with unsupported RHS
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def test(code):
|
|||||||
print("NotImplementedError")
|
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:
|
try:
|
||||||
eval("1and 0")
|
eval("1and 0")
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ def print_exc(e):
|
|||||||
print_exception(e, buf)
|
print_exception(e, buf)
|
||||||
s = buf.getvalue()
|
s = buf.getvalue()
|
||||||
for l in s.split("\n"):
|
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 "):
|
if l.startswith(" File "):
|
||||||
l = l.split('"')
|
l = l.split('"')
|
||||||
print(l[0], l[2])
|
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
|
# each traceback entry. In this case, we know that offending line
|
||||||
# has 4-space indent, so filter it out.
|
# has 4-space indent, so filter it out.
|
||||||
elif not l.startswith(" "):
|
elif not l.startswith(" "):
|
||||||
@@ -89,7 +89,7 @@ try:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print_exc(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"):
|
if hasattr(sys, "print_exception"):
|
||||||
try:
|
try:
|
||||||
sys.print_exception(Exception, 1)
|
sys.print_exception(Exception, 1)
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ from frzqstr import returns_NULL
|
|||||||
|
|
||||||
print(returns_NULL())
|
print(returns_NULL())
|
||||||
|
|
||||||
# test for freeze_mpy
|
# test for freeze_mpy (importing prints several lines)
|
||||||
import frozentest
|
import frozentest
|
||||||
|
|
||||||
print(frozentest.__file__)
|
print(frozentest.__file__)
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ b'\x00\xff'
|
|||||||
frzmpy4 1
|
frzmpy4 1
|
||||||
frzmpy4 2
|
frzmpy4 2
|
||||||
NULL
|
NULL
|
||||||
uPy
|
interned
|
||||||
a long string that is not interned
|
a long string that is not interned
|
||||||
a string that has unicode αβγ chars
|
a string that has unicode αβγ chars
|
||||||
b'bytes 1234\x01'
|
b'bytes 1234\x01'
|
||||||
|
|||||||
Reference in New Issue
Block a user