From a79a6ab3641e3536e509278706e7ac4de01a8126 Mon Sep 17 00:00:00 2001 From: David Grayson Date: Sun, 4 Jun 2023 19:55:41 -0700 Subject: [PATCH 0001/4300] py/builtinimport: Remove partially-loaded modules from sys.modules. Prior to this commit, importing a module that exists but has a syntax error or some other problem that happens at import time would result in a potentially-incomplete module object getting added to sys.modules. Subsequent imports would use that object, resulting in confusing error messages that hide the root cause of the problem. This commit fixes that issue by removing the failed module from sys.modules using the new NLR callback mechanism. Note that it is still important to add the module to sys.modules while the import is happening so that we can support circular imports just like CPython does. Fixes issue #967. Signed-off-by: David Grayson --- py/builtinimport.c | 20 +++++++++++++++- tests/cpydiff/core_import_prereg.py | 18 -------------- tests/import/broken/pkg2_and_zerodiv.py | 2 ++ tests/import/broken/zerodiv.py | 1 + tests/import/circular/main.py | 4 ++++ tests/import/circular/sub.py | 3 +++ tests/import/import_broken.py | 32 +++++++++++++++++++++++++ tests/import/import_circular.py | 1 + 8 files changed, 62 insertions(+), 19 deletions(-) delete mode 100644 tests/cpydiff/core_import_prereg.py create mode 100644 tests/import/broken/pkg2_and_zerodiv.py create mode 100644 tests/import/broken/zerodiv.py create mode 100644 tests/import/circular/main.py create mode 100644 tests/import/circular/sub.py create mode 100644 tests/import/import_broken.py create mode 100644 tests/import/import_circular.py diff --git a/py/builtinimport.c b/py/builtinimport.c index de4ea17f38c..8827be61233 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -346,6 +346,17 @@ STATIC void evaluate_relative_import(mp_int_t level, const char **module_name, s *module_name_len = new_module_name_len; } +typedef struct _nlr_jump_callback_node_unregister_module_t { + nlr_jump_callback_node_t callback; + qstr name; +} nlr_jump_callback_node_unregister_module_t; + +STATIC void unregister_module_from_nlr_jump_callback(void *ctx_in) { + nlr_jump_callback_node_unregister_module_t *ctx = ctx_in; + mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; + mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(ctx->name), MP_MAP_LOOKUP_REMOVE_IF_FOUND); +} + // Load a module at the specified absolute path, possibly as a submodule of the given outer module. // full_mod_name: The full absolute path up to this level (e.g. "foo.bar.baz"). // level_mod_name: The final component of the path (e.g. "baz"). @@ -467,8 +478,13 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, // Module was found on the filesystem/frozen, try and load it. DEBUG_printf("Found path to load: %.*s\n", (int)vstr_len(&path), vstr_str(&path)); - // Prepare for loading from the filesystem. Create a new shell module. + // Prepare for loading from the filesystem. Create a new shell module + // and register it in sys.modules. Also make sure we remove it if + // there is any problem below. module_obj = mp_obj_new_module(full_mod_name); + nlr_jump_callback_node_unregister_module_t ctx; + ctx.name = full_mod_name; + nlr_push_jump_callback(&ctx.callback, unregister_module_from_nlr_jump_callback); #if MICROPY_MODULE_OVERRIDE_MAIN_IMPORT // If this module is being loaded via -m on unix, then @@ -526,6 +542,8 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, mp_store_attr(outer_module_obj, level_mod_name, module_obj); } + nlr_pop_jump_callback(false); + return module_obj; } diff --git a/tests/cpydiff/core_import_prereg.py b/tests/cpydiff/core_import_prereg.py deleted file mode 100644 index 3ce2340c68d..00000000000 --- a/tests/cpydiff/core_import_prereg.py +++ /dev/null @@ -1,18 +0,0 @@ -""" -categories: Core,import -description: Failed to load modules are still registered as loaded -cause: To make module handling more efficient, it's not wrapped with exception handling. -workaround: Test modules before production use; during development, use ``del sys.modules["name"]``, or just soft or hard reset the board. -""" -import sys - -try: - from modules import foo -except NameError as e: - print(e) -try: - from modules import foo - - print("Should not get here") -except NameError as e: - print(e) diff --git a/tests/import/broken/pkg2_and_zerodiv.py b/tests/import/broken/pkg2_and_zerodiv.py new file mode 100644 index 00000000000..3580628ff51 --- /dev/null +++ b/tests/import/broken/pkg2_and_zerodiv.py @@ -0,0 +1,2 @@ +import pkg2 +import broken.zerodiv diff --git a/tests/import/broken/zerodiv.py b/tests/import/broken/zerodiv.py new file mode 100644 index 00000000000..72dca4d5e47 --- /dev/null +++ b/tests/import/broken/zerodiv.py @@ -0,0 +1 @@ +1 / 0 diff --git a/tests/import/circular/main.py b/tests/import/circular/main.py new file mode 100644 index 00000000000..5d63d507c32 --- /dev/null +++ b/tests/import/circular/main.py @@ -0,0 +1,4 @@ +x = 1 +import circular.sub + +print(circular.sub.y) diff --git a/tests/import/circular/sub.py b/tests/import/circular/sub.py new file mode 100644 index 00000000000..50d7afe07bc --- /dev/null +++ b/tests/import/circular/sub.py @@ -0,0 +1,3 @@ +from circular.main import x + +y = x + 20 diff --git a/tests/import/import_broken.py b/tests/import/import_broken.py new file mode 100644 index 00000000000..3c7cf4a4985 --- /dev/null +++ b/tests/import/import_broken.py @@ -0,0 +1,32 @@ +import sys, pkg + +# Modules we import are usually added to sys.modules. +print("pkg" in sys.modules) + +try: + from broken.zerodiv import x +except Exception as e: + print(e.__class__.__name__) + +# The broken module we tried to import should not be in sys.modules. +print("broken.zerodiv" in sys.modules) + +# If we try to import the module again, the code should +# run again and we should get the same error. +try: + from broken.zerodiv import x +except Exception as e: + print(e.__class__.__name__) + +# Import a module that successfully imports some other modules +# before importing the problematic module. +try: + import broken.pkg2_and_zerodiv +except ZeroDivisionError: + pass + +print("pkg2" in sys.modules) +print("pkg2.mod1" in sys.modules) +print("pkg2.mod2" in sys.modules) +print("broken.zerodiv" in sys.modules) +print("broken.pkg2_and_zerodiv" in sys.modules) diff --git a/tests/import/import_circular.py b/tests/import/import_circular.py new file mode 100644 index 00000000000..388efdd1308 --- /dev/null +++ b/tests/import/import_circular.py @@ -0,0 +1 @@ +import circular.main From bf7d3ad8c69431d7bb8d1188484996af94e78990 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Wed, 24 May 2023 16:13:01 +0200 Subject: [PATCH 0002/4300] samd/boards: Rename flash pins consistently for QSPI and SPI. For SAMD21 devices, the board flash signals must be named in pins.csv as FLASH_MOSI, FLASH_MISO, FLASH_SCK, FLASH_CS for creating the SPI object. And rename the QSPI pins to QSPI_xxxx instead of FLASH_xxx. Signed-off-by: robert-hh --- docs/samd/pinout.rst | 48 +++++++++---------- .../ADAFRUIT_FEATHER_M0_EXPRESS/pins.csv | 6 +-- .../ADAFRUIT_FEATHER_M4_EXPRESS/pins.csv | 13 ++--- .../ADAFRUIT_ITSYBITSY_M4_EXPRESS/pins.csv | 13 ++--- ports/samd/boards/MINISAM_M4/pins.csv | 9 ++++ ports/samd/boards/SEEED_WIO_TERMINAL/pins.csv | 7 +++ 6 files changed, 57 insertions(+), 39 deletions(-) diff --git a/docs/samd/pinout.rst b/docs/samd/pinout.rst index 212275a0143..5fe1e14ecb3 100644 --- a/docs/samd/pinout.rst +++ b/docs/samd/pinout.rst @@ -160,14 +160,14 @@ Pin GPIO Pin name IRQ ADC ADC Serial Serial TC PWM PWM 22 PA22 D13 6 - - 3/0 5/1 4/0 1/6 0/2 34 PB02 DOTSTAR_CLK 2 14 - - 5/0 6/0 2/2 - 35 PB03 DOTSTAR_DATA 9 15 - - 5/1 6/1 - - - 43 PB11 FLASH_CS 12 - - - 4/3 5/1 0/5 1/1 - 11 PA11 FLASH_HOLD 11 11 - 0/3 2/3 1/1 0/3 1/7 - 9 PA09 FLASH_MISO 9 9 3 0/1 2/0 0/1 0/1 1/5 - 8 PA08 FLASH_MOSI - 8 2 0/0 2/1 0/0 0/0 1/4 - 42 PB10 FLASH_SCK 10 - - - 4/2 5/0 0/4 1/0 - 10 PA10 FLASH_WP 10 10 - 0/2 2/2 1/0 0/2 1/6 55 PB23 MISO 7 - - 1/3 5/3 7/1 - - 0 PA00 MOSI 0 - - - 1/0 2/0 - - + 43 PB11 QSPI_CS 12 - - - 4/3 5/1 0/5 1/1 + 8 PA08 QSPI_D0 - 8 2 0/0 2/1 0/0 0/0 1/4 + 9 PA09 QSPI_D1 9 9 3 0/1 2/0 0/1 0/1 1/5 + 10 PA10 QSPI_D2 10 10 - 0/2 2/2 1/0 0/2 1/6 + 11 PA11 QSPI_D3 11 11 - 0/3 2/3 1/1 0/3 1/7 + 42 PB10 QSPI_SCK 10 - - - 4/2 5/0 0/4 1/0 1 PA01 SCK 1 - - - 1/1 2/1 - - 13 PA13 SCL 13 - - 2/1 4/0 2/1 0/7 1/3 12 PA12 SDA 12 - - 2/0 4/1 2/0 0/6 1/2 @@ -288,15 +288,15 @@ Pin GPIO Pin name IRQ ADC ADC Serial Serial TC PWM PWM 21 PA21 D11 5 - - 5/3 3/3 7/1 1/5 0/1 22 PA22 D12 6 - - 3/0 5/1 4/0 1/6 0/2 23 PA23 D13 7 - - 3/1 5/0 4/1 1/7 0/3 - 43 PB11 FLASH_CS 12 - - - 4/3 5/1 0/5 1/1 - 11 PA11 FLASH_HOLD 11 11 - 0/3 2/3 1/1 0/3 1/7 - 9 PA09 FLASH_MISO 9 9 3 0/1 2/0 0/1 0/1 1/5 - 8 PA08 FLASH_MOSI - 8 2 0/0 2/1 0/0 0/0 1/4 - 42 PB10 FLASH_SCK 10 - - - 4/2 5/0 0/4 1/0 - 10 PA10 FLASH_WP 10 10 - 0/2 2/2 1/0 0/2 1/6 54 PB22 MISO 22 - - 1/2 5/2 7/0 - - 55 PB23 MOSI 7 - - 1/3 5/3 7/1 - - 35 PB03 NEOPIXEL 9 15 - - 5/1 6/1 - - + 43 PB11 QSPI_CS 12 - - - 4/3 5/1 0/5 1/1 + 8 PA08 QSPI_D0 - 8 2 0/0 2/1 0/0 0/0 1/4 + 9 PA09 QSPI_D1 9 9 3 0/1 2/0 0/1 0/1 1/5 + 10 PA10 QSPI_D2 10 10 - 0/2 2/2 1/0 0/2 1/6 + 11 PA11 QSPI_D3 11 11 - 0/3 2/3 1/1 0/3 1/7 + 42 PB10 QSPI_SCK 10 - - - 4/2 5/0 0/4 1/0 17 PA17 SCK 1 - - 1/1 3/0 2/1 1/1 0/5 13 PA13 SCL 13 - - 2/1 4/0 2/1 0/7 1/3 12 PA12 SDA 12 - - 2/0 4/1 2/0 0/6 1/2 @@ -650,6 +650,12 @@ Pin GPIO Pin name IRQ ADC ADC Serial Serial TC PWM PWM 15 PA15 LED 15 - - 2/3 4/3 3/1 2/1 1/3 55 PB23 MISO 7 - - 1/3 5/3 7/1 - - 54 PB22 MOSI 22 - - 1/2 5/2 7/0 - - + 43 PB11 QSPI_CS 12 - - - 4/3 5/1 0/5 1/1 + 8 PA08 QSPI_D0 - 8 2 0/0 2/1 0/0 0/0 1/4 + 9 PA09 QSPI_D1 9 9 3 0/1 2/0 0/1 0/1 1/5 + 10 PA10 QSPI_D2 10 10 - 0/2 2/2 1/0 0/2 1/6 + 11 PA11 QSPI_D3 11 11 - 0/3 2/3 1/1 0/3 1/7 + 42 PB10 QSPI_SCK 10 - - - 4/2 5/0 0/4 1/0 1 PA01 SCK 1 - - - 1/1 2/1 - - 13 PA13 SCL 13 - - 2/1 4/0 2/1 0/7 1/3 12 PA12 SDA 12 - - 2/0 4/1 2/0 0/6 1/2 @@ -657,17 +663,11 @@ Pin GPIO Pin name IRQ ADC ADC Serial Serial TC PWM PWM 31 PA31 SWDIO 15 - - 7/3 1/3 6/1 2/1 - 24 PA24 USB_DM 8 - - 3/2 5/2 5/0 2/2 - 25 PA25 USB_DP 9 - - 3/3 5/3 5/1 - - - 8 PA08 - - 8 2 0/0 2/1 0/0 0/0 1/4 - 9 PA09 - 9 9 3 0/1 2/0 0/1 0/1 1/5 - 10 PA10 - 10 10 - 0/2 2/2 1/0 0/2 1/6 - 11 PA11 - 11 11 - 0/3 2/3 1/1 0/3 1/7 14 PA14 - 14 - - 2/2 4/2 3/0 2/0 1/2 18 PA18 - 2 - - 1/2 3/2 3/0 1/2 0/6 22 PA22 - 6 - - 3/0 5/1 4/0 1/6 0/2 23 PA23 - 7 - - 3/1 5/0 4/1 1/7 0/3 27 PA27 - 11 - - - - - - - - 42 PB10 - 10 - - - 4/2 5/0 0/4 1/0 - 43 PB11 - 12 - - - 4/3 5/1 0/5 1/1 === ==== ============ ==== ==== ==== ====== ====== ===== ===== ===== For the definition of the table columns see the explanation at the table for @@ -734,6 +734,12 @@ Pin GPIO Pin name IRQ ADC ADC Serial Serial TC PWM PWM 117 PD21 SD_DET 11 - - 1/3 3/3 - 1/1 - 83 PC19 SD_CS 3 - - 6/3 0/3 - 0/3 - 82 PC18 SD_MISO 2 - - 6/2 0/2 - 0/2 - + 43 PB11 QSPI_CS 12 - - - 4/3 5/1 0/5 1/1 + 8 PA08 QSPI_D0 - 8 2 0/0 2/1 0/0 0/0 1/4 + 9 PA09 QSPI_D1 9 9 3 0/1 2/0 0/1 0/1 1/5 + 10 PA10 QSPI_D2 10 10 - 0/2 2/2 1/0 0/2 1/6 + 11 PA11 QSPI_D3 11 11 - 0/3 2/3 1/1 0/3 1/7 + 42 PB10 QSPI_SCK 10 - - - 4/2 5/0 0/4 1/0 80 PC16 SD_MOSI 0 - - 6/0 0/1 - 0/0 - 81 PC17 SD_SCK 1 - - 6/1 0/0 - 0/1 - 30 PA30 SWCLK 14 - - 7/2 1/2 6/0 2/0 - @@ -750,17 +756,11 @@ Pin GPIO Pin name IRQ ADC ADC Serial Serial TC PWM PWM 2 PA02 - 2 0 - - - - - - 3 PA03 - 3 10 - - - - - - 5 PA05 - 5 5 - - 0/1 0/1 - - - 8 PA08 - - 8 2 0/0 2/1 0/0 0/0 1/4 - 9 PA09 - 9 9 3 0/1 2/0 0/1 0/1 1/5 - 10 PA10 - 10 10 - 0/2 2/2 1/0 0/2 1/6 - 11 PA11 - 11 11 - 0/3 2/3 1/1 0/3 1/7 14 PA14 - 14 - - 2/2 4/2 3/0 2/0 1/2 18 PA18 - 2 - - 1/2 3/2 3/0 1/2 0/6 19 PA19 - 3 - - 1/3 3/3 3/1 1/3 0/7 23 PA23 - 7 - - 3/1 5/0 4/1 1/7 0/3 27 PA27 - 11 - - - - - - - - 42 PB10 - 10 - - - 4/2 5/0 0/4 1/0 - 43 PB11 - 12 - - - 4/3 5/1 0/5 1/1 46 PB14 - 14 - - 4/2 - 5/0 4/0 0/2 49 PB17 - 1 - - 5/1 - 6/1 3/1 0/5 54 PB22 - 22 - - 1/2 5/2 7/0 - - diff --git a/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/pins.csv b/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/pins.csv index 35b6d1fd4e0..65362770624 100644 --- a/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/pins.csv +++ b/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/pins.csv @@ -8,9 +8,9 @@ PIN_PB03,LED_RX PIN_PA11,D0 PIN_PA10,D1 -PIN_PA14,D2 -PIN_PA09,D3 -PIN_PA08,D4 +PIN_PA08,FLASH_MOSI +PIN_PA14,FLASH_MISO +PIN_PA09,FLASH_SCK PIN_PA15,D5 PIN_PA20,D6 PIN_PA21,D7 diff --git a/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/pins.csv b/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/pins.csv index ad8449ac9ec..df3373f246a 100644 --- a/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/pins.csv +++ b/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/pins.csv @@ -28,12 +28,13 @@ PIN_PA17,SCK PIN_PB01,VDIV PIN_PA03,AREF PIN_PB03,NEOPIXEL -PIN_PB11,FLASH_CS -PIN_PB10,FLASH_SCK -PIN_PA08,FLASH_MOSI -PIN_PA09,FLASH_MISO -PIN_PA10,FLASH_WP -PIN_PA11,FLASH_HOLD + +PIN_PB11,QSPI_CS +PIN_PB10,QSPI_SCK +PIN_PA08,QSPI_D0 +PIN_PA09,QSPI_D1 +PIN_PA10,QSPI_D2 +PIN_PA11,QSPI_D3 PIN_PA24,USB_DM PIN_PA25,USB_DP diff --git a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/pins.csv b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/pins.csv index 43c8e9a64a9..b63a1f4b135 100644 --- a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/pins.csv +++ b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/pins.csv @@ -28,12 +28,13 @@ PIN_PB23,MISO PIN_PA01,SCK PIN_PB02,DOTSTAR_CLK PIN_PB03,DOTSTAR_DATA -PIN_PB11,FLASH_CS -PIN_PB10,FLASH_SCK -PIN_PA08,FLASH_MOSI -PIN_PA09,FLASH_MISO -PIN_PA10,FLASH_WP -PIN_PA11,FLASH_HOLD + +PIN_PB11,QSPI_CS +PIN_PB10,QSPI_SCK +PIN_PA08,QSPI_D0 +PIN_PA09,QSPI_D1 +PIN_PA10,QSPI_D2 +PIN_PA11,QSPI_D3 PIN_PA24,USB_DM PIN_PA25,USB_DP diff --git a/ports/samd/boards/MINISAM_M4/pins.csv b/ports/samd/boards/MINISAM_M4/pins.csv index 793e523fcd9..3ea5f85cbac 100644 --- a/ports/samd/boards/MINISAM_M4/pins.csv +++ b/ports/samd/boards/MINISAM_M4/pins.csv @@ -26,6 +26,15 @@ PIN_PA01,SCK PIN_PB03,DOTSTAR_DATA PIN_PB02,DOTSTAR_CLK +PIN_PB11,QSPI_CS +PIN_PB10,QSPI_SCK +PIN_PA08,QSPI_D0 +PIN_PA09,QSPI_D1 +PIN_PA10,QSPI_D2 +PIN_PA11,QSPI_D3 + +PIN_PA15,LED + PIN_PA24,USB_DM PIN_PA25,USB_DP PIN_PA26,USB_SOF diff --git a/ports/samd/boards/SEEED_WIO_TERMINAL/pins.csv b/ports/samd/boards/SEEED_WIO_TERMINAL/pins.csv index 55cbb5bf049..c32108b9f72 100644 --- a/ports/samd/boards/SEEED_WIO_TERMINAL/pins.csv +++ b/ports/samd/boards/SEEED_WIO_TERMINAL/pins.csv @@ -58,6 +58,13 @@ PIN_PC13,LCD_YD PIN_PC30,MIC PIN_PD11,BUZZER +PIN_PB11,QSPI_CS +PIN_PB10,QSPI_SCK +PIN_PA08,QSPI_D0 +PIN_PA09,QSPI_D1 +PIN_PA10,QSPI_D2 +PIN_PA11,QSPI_D3 + PIN_PA15,LED_BLUE PIN_PC05,LED_LCD From 5561130c3f220e52fc878b683fc90ecb031427e6 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Wed, 24 May 2023 16:14:47 +0200 Subject: [PATCH 0003/4300] samd/samd_spiflash: Add SPI flash driver and configure it accordingly. The SPI flash driver includes the block device for being used as a filesystem. It provides the same methods as the driver for the internal flash. Signed-off-by: robert-hh --- .../mpconfigboard.h | 3 + .../mpconfigboard.h | 3 + ports/samd/samd_spiflash.c | 299 ++++++++++++++++++ 3 files changed, 305 insertions(+) create mode 100644 ports/samd/samd_spiflash.c diff --git a/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.h b/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.h index 815597899c4..880df8d2003 100644 --- a/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.h +++ b/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.h @@ -2,3 +2,6 @@ #define MICROPY_HW_MCU_NAME "SAMD21G18A" #define MICROPY_HW_XOSC32K (1) + +#define MICROPY_HW_SPIFLASH (1) +#define MICROPY_HW_SPIFLASH_ID (2) diff --git a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.h b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.h index 160c61ea2aa..16018fdc563 100644 --- a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.h +++ b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.h @@ -2,3 +2,6 @@ #define MICROPY_HW_MCU_NAME "SAMD21G18A" #define MICROPY_HW_DFLL_USB_SYNC (1) + +#define MICROPY_HW_SPIFLASH (1) +#define MICROPY_HW_SPIFLASH_ID (5) diff --git a/ports/samd/samd_spiflash.c b/ports/samd/samd_spiflash.c new file mode 100644 index 00000000000..eaa0ec14348 --- /dev/null +++ b/ports/samd/samd_spiflash.c @@ -0,0 +1,299 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019-2020 Peter Hinch + * Copyright (c) 2023 Robert Hammelrath + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include +#include "py/obj.h" +#include "py/runtime.h" +#include "py/mphal.h" +#include "extmod/machine_spi.h" +#include "extmod/vfs.h" +#include "modmachine.h" +#include "pin_af.h" + +#if MICROPY_HW_SPIFLASH + +#define _READ_INDEX (0) +#define _PROGRAM_PAGE_INDEX (1) +#define _SECTOR_ERASE_INDEX (2) + +const uint8_t _COMMANDS_24BIT[] = {0x03, 0x02, 0x20}; // READ, PROGRAM_PAGE, ERASE_4K +const uint8_t _COMMANDS_32BIT[] = {0x13, 0x12, 0x21}; // READ, PROGRAM_PAGE, ERASE_4K + +#define COMMAND_JEDEC_ID (0x9F) +#define COMMAND_READ_STATUS (0x05) +#define COMMAND_WRITE_ENABLE (0x06) +#define COMMAND_READ_SFDP (0x5A) +#define PAGE_SIZE (256) +#define SECTOR_SIZE (4096) + +typedef struct _spiflash_obj_t { + mp_obj_base_t base; + mp_obj_base_t *spi; + mp_hal_pin_obj_t cs; + bool addr_is_32bit; + uint16_t pagesize; + uint16_t sectorsize; + const uint8_t *commands; + uint32_t size; +} spiflash_obj_t; + +extern const mp_obj_type_t samd_spiflash_type; + +// The SPIflash object is a singleton +static spiflash_obj_t spiflash_obj = { + { &samd_spiflash_type }, NULL, 0, false, PAGE_SIZE, SECTOR_SIZE, NULL, 0 +}; + +static void spi_transfer(mp_obj_base_t *spi, size_t len, const uint8_t *src, uint8_t *dest) { + mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t *)MP_OBJ_TYPE_GET_SLOT(spi->type, protocol); + spi_p->transfer(spi, len, src, dest); +} + +static void wait(spiflash_obj_t *self) { + uint8_t msg[2]; + uint32_t timeout = 100000; + + // each loop takes at least about 5us @ 120Mhz. So a timeout of + // 100000 wait 500ms max. at 120Mhz. Sector erase lasts about + // 100ms worst case, page write is < 1ms. + do { + msg[0] = COMMAND_READ_STATUS; + mp_hal_pin_write(self->cs, 0); + spi_transfer((mp_obj_base_t *)self->spi, 2, msg, msg); + mp_hal_pin_write(self->cs, 1); + } while (msg[1] != 0 && timeout-- > 0); +} + +static void get_id(spiflash_obj_t *self, uint8_t id[3]) { + uint8_t msg[1]; + + msg[0] = COMMAND_JEDEC_ID; + mp_hal_pin_write(self->cs, 0); + spi_transfer(self->spi, 1, msg, NULL); + spi_transfer(self->spi, 3, id, id); + mp_hal_pin_write(self->cs, 1); +} +static void write_addr(spiflash_obj_t *self, uint8_t cmd, uint32_t addr) { + uint8_t msg[5]; + uint8_t index = 1; + msg[0] = cmd; + if (self->addr_is_32bit) { + msg[index++] = addr >> 24; + } + msg[index++] = (addr >> 16) & 0xff; + msg[index++] = (addr >> 8) & 0xff; + msg[index++] = addr & 0xff; + mp_hal_pin_write(self->cs, 0); + spi_transfer(self->spi, self->addr_is_32bit ? 5 : 4, msg, msg); +} + +static void write_enable(spiflash_obj_t *self) { + uint8_t msg[1]; + + msg[0] = COMMAND_WRITE_ENABLE; + mp_hal_pin_write(self->cs, 0); + spi_transfer(self->spi, 1, msg, NULL); + mp_hal_pin_write(self->cs, 1); +} + +static void get_sfdp(spiflash_obj_t *self, uint32_t addr, uint8_t *buffer, int size) { + uint8_t dummy[1]; + write_addr(self, COMMAND_READ_SFDP, addr); + spi_transfer(self->spi, 1, dummy, NULL); + spi_transfer(self->spi, size, buffer, buffer); + mp_hal_pin_write(self->cs, 1); +} + +STATIC mp_obj_t spiflash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + mp_arg_check_num(n_args, n_kw, 0, 0, false); + + // Set up the object + spiflash_obj_t *self = &spiflash_obj; + + mp_obj_t spi_args[] = { + MP_OBJ_NEW_SMALL_INT(MICROPY_HW_SPIFLASH_ID), + MP_OBJ_NEW_SMALL_INT(24000000), // baudrate + MP_OBJ_NEW_QSTR(MP_QSTR_mosi), MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_MOSI), + MP_OBJ_NEW_QSTR(MP_QSTR_miso), MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_MISO), + MP_OBJ_NEW_QSTR(MP_QSTR_sck), MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_SCK), + }; + self->spi = MP_OBJ_TYPE_GET_SLOT(&machine_spi_type, make_new)((mp_obj_t)&machine_spi_type, 2, 3, spi_args); + + mp_obj_t pin_args[] = { + MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_CS), + MP_ROM_INT(1), + }; + machine_pin_obj_t *cs = MP_OBJ_TYPE_GET_SLOT(&machine_pin_type, make_new)((mp_obj_t)&machine_pin_type, 2, 0, pin_args); + self->cs = cs->pin_id; + mp_hal_pin_write(self->cs, 1); + + wait(self); + + // Get the flash size from the device ID (default) + uint8_t id[3]; + get_id(self, id); + if (id[1] == 0x84 && id[2] == 1) { // Adesto + self->size = 512 * 1024; + } else if (id[1] == 0x1f && id[2] == 1) { // Atmel / Renesas + self->size = 1024 * 1024; + } else { + self->size = 1 << id[2]; + } + + // Get the addr_is_32bit flag and the sector size + uint8_t buffer[128]; + get_sfdp(self, 0, buffer, 16); // get the header + int len = MIN(buffer[11] * 4, sizeof(buffer)); + if (len >= 29) { + int addr = buffer[12] + (buffer[13] << 8) + (buffer[14] << 16); + get_sfdp(self, addr, buffer, len); // Get the JEDEC mandatory table + self->sectorsize = 1 << buffer[28]; + self->addr_is_32bit = ((buffer[2] >> 1) & 0x03) != 0; + } + self->commands = self->addr_is_32bit ? _COMMANDS_32BIT : _COMMANDS_24BIT; + + return self; +} + +STATIC mp_obj_t spiflash_read(spiflash_obj_t *self, uint32_t addr, uint8_t *dest, uint32_t len) { + if (len > 0) { + write_addr(self, self->commands[_READ_INDEX], addr); + spi_transfer(self->spi, len, dest, dest); + mp_hal_pin_write(self->cs, 1); + } + + return mp_const_none; +} + +STATIC mp_obj_t spiflash_write(spiflash_obj_t *self, uint32_t addr, uint8_t *src, uint32_t len) { + uint32_t length = len; + uint32_t pos = 0; + uint8_t *buf = src; + + while (pos < length) { + uint16_t maxsize = self->pagesize - pos % self->pagesize; + uint16_t size = (length - pos) > maxsize ? maxsize : length - pos; + + write_enable(self); + write_addr(self, self->commands[_PROGRAM_PAGE_INDEX], addr); + spi_transfer(self->spi, size, buf + pos, NULL); + mp_hal_pin_write(self->cs, 1); + wait(self); + + addr += size; + pos += size; + } + + return mp_const_none; +} + +STATIC mp_obj_t spiflash_erase(spiflash_obj_t *self, uint32_t addr) { + write_enable(self); + write_addr(self, self->commands[_SECTOR_ERASE_INDEX], addr); + mp_hal_pin_write(self->cs, 1); + wait(self); + + return mp_const_none; +} + +STATIC mp_obj_t spiflash_readblocks(size_t n_args, const mp_obj_t *args) { + spiflash_obj_t *self = MP_OBJ_TO_PTR(args[0]); + uint32_t offset = (mp_obj_get_int(args[1]) * self->sectorsize); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE); + if (n_args == 4) { + offset += mp_obj_get_int(args[3]); + } + + // Read data to flash (adf4 API) + spiflash_read(self, offset, bufinfo.buf, bufinfo.len); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(spiflash_readblocks_obj, 3, 4, spiflash_readblocks); + +STATIC mp_obj_t spiflash_writeblocks(size_t n_args, const mp_obj_t *args) { + spiflash_obj_t *self = MP_OBJ_TO_PTR(args[0]); + uint32_t offset = (mp_obj_get_int(args[1]) * self->sectorsize); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); + if (n_args == 3) { + spiflash_erase(self, offset); + // TODO check return value + } else { + offset += mp_obj_get_int(args[3]); + } + // Write data to flash (adf4 API) + spiflash_write(self, offset, bufinfo.buf, bufinfo.len); + // TODO check return value + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(spiflash_writeblocks_obj, 3, 4, spiflash_writeblocks); + +STATIC mp_obj_t spiflash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg_in) { + spiflash_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t cmd = mp_obj_get_int(cmd_in); + + switch (cmd) { + case MP_BLOCKDEV_IOCTL_INIT: + return MP_OBJ_NEW_SMALL_INT(0); + case MP_BLOCKDEV_IOCTL_DEINIT: + return MP_OBJ_NEW_SMALL_INT(0); + case MP_BLOCKDEV_IOCTL_SYNC: + return MP_OBJ_NEW_SMALL_INT(0); + case MP_BLOCKDEV_IOCTL_BLOCK_COUNT: + return MP_OBJ_NEW_SMALL_INT(self->size / self->sectorsize); + case MP_BLOCKDEV_IOCTL_BLOCK_SIZE: + return MP_OBJ_NEW_SMALL_INT(self->sectorsize); + case MP_BLOCKDEV_IOCTL_BLOCK_ERASE: { + spiflash_erase(self, mp_obj_get_int(arg_in) * self->sectorsize); + // TODO check return value + return MP_OBJ_NEW_SMALL_INT(0); + } + default: + return mp_const_none; + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(spiflash_ioctl_obj, spiflash_ioctl); + +STATIC const mp_rom_map_elem_t spiflash_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_readblocks), MP_ROM_PTR(&spiflash_readblocks_obj) }, + { MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&spiflash_writeblocks_obj) }, + { MP_ROM_QSTR(MP_QSTR_ioctl), MP_ROM_PTR(&spiflash_ioctl_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(spiflash_locals_dict, spiflash_locals_dict_table); + +MP_DEFINE_CONST_OBJ_TYPE( + samd_spiflash_type, + MP_QSTR_Flash, + MP_TYPE_FLAG_NONE, + make_new, spiflash_make_new, + locals_dict, &spiflash_locals_dict + ); + +#endif // #if MICROPY_HW_SPIFLASH From 2b5a5a0f35b325e14268f8f48ac8b5022da87691 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Wed, 24 May 2023 16:16:40 +0200 Subject: [PATCH 0004/4300] samd/samd_qspiflash: Add QSPI flash driver and configure it accordingly. The QSPI driver provides the interface for using an on-board QSPI flash for the filesystem. It provides the same methods as the driver for the internal flash and uses the same name. Therefore, only one of the drivers for internal flash, SPI flash and QSPI flash must be enabled at a time. Signed-off-by: robert-hh --- drivers/memory/external_flash_device.h | 461 ++++++++++++++++ .../mpconfigboard.h | 2 + .../mpconfigboard.h | 2 + ports/samd/boards/MINISAM_M4/mpconfigboard.h | 2 + .../boards/SEEED_WIO_TERMINAL/mpconfigboard.h | 2 + .../mpconfigboard.h | 5 + ports/samd/pin_af.h | 3 + ports/samd/samd_qspiflash.c | 491 ++++++++++++++++++ 8 files changed, 968 insertions(+) create mode 100644 drivers/memory/external_flash_device.h create mode 100644 ports/samd/samd_qspiflash.c diff --git a/drivers/memory/external_flash_device.h b/drivers/memory/external_flash_device.h new file mode 100644 index 00000000000..03798446036 --- /dev/null +++ b/drivers/memory/external_flash_device.h @@ -0,0 +1,461 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_EXTERNAL_FLASH_DEVICES_H +#define MICROPY_INCLUDED_ATMEL_SAMD_EXTERNAL_FLASH_DEVICES_H + +#include +#include + +typedef struct { + uint32_t total_size; + uint16_t start_up_time_us; + + // Three response bytes to 0x9f JEDEC ID command. + uint8_t manufacturer_id; + uint8_t memory_type; + uint8_t capacity; + + // Max clock speed for all operations and the fastest read mode. + uint8_t max_clock_speed_mhz; + + // Bitmask for Quad Enable bit if present. 0x00 otherwise. This is for the highest byte in the + // status register. + uint8_t quad_enable_bit_mask; + + bool has_sector_protection : 1; + + // Supports the 0x0b fast read command with 8 dummy cycles. + bool supports_fast_read : 1; + + // Supports the fast read, quad output command 0x6b with 8 dummy cycles. + bool supports_qspi : 1; + + // Supports the quad input page program command 0x32. This is known as 1-1-4 because it only + // uses all four lines for data. + bool supports_qspi_writes : 1; + + // Requires a separate command 0x31 to write to the second byte of the status register. + // Otherwise two byte are written via 0x01. + bool write_status_register_split : 1; + + // True when the status register is a single byte. This implies the Quad Enable bit is in the + // first byte and the Read Status Register 2 command (0x35) is unsupported. + bool single_status_byte : 1; +} external_flash_device; + +// Settings for the Adesto Tech AT25DF081A 1MiB SPI flash. Its on the SAMD21 +// Xplained board. +// Datasheet: https://www.adestotech.com/wp-content/uploads/doc8715.pdf +#define AT25DF081A { \ + .total_size = (1 << 20), /* 1 MiB */ \ + .start_up_time_us = 10000, \ + .manufacturer_id = 0x1f, \ + .memory_type = 0x45, \ + .capacity = 0x01, \ + .max_clock_speed_mhz = 85, \ + .quad_enable_bit_mask = 0x00, \ + .has_sector_protection = true, \ + .supports_fast_read = true, \ + .supports_qspi = false, \ + .supports_qspi_writes = false, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Gigadevice GD25Q16C 2MiB SPI flash. +// Datasheet: http://www.gigadevice.com/datasheet/gd25q16c/ +#define GD25Q16C { \ + .total_size = (1 << 21), /* 2 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xc8, \ + .memory_type = 0x40, \ + .capacity = 0x15, \ + .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Gigadevice GD25Q64C 8MiB SPI flash. +// Datasheet: http://www.elm-tech.com/en/products/spi-flash-memory/gd25q64/gd25q64.pdf +#define GD25Q64C { \ + .total_size = (1 << 23), /* 8 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xc8, \ + .memory_type = 0x40, \ + .capacity = 0x17, \ + .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = true, \ + .single_status_byte = false, \ +} + +// Settings for the Cypress (was Spansion) S25FL064L 8MiB SPI flash. +// Datasheet: http://www.cypress.com/file/316661/download +#define S25FL064L { \ + .total_size = (1 << 23), /* 8 MiB */ \ + .start_up_time_us = 300, \ + .manufacturer_id = 0x01, \ + .memory_type = 0x60, \ + .capacity = 0x17, \ + .max_clock_speed_mhz = 108, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Cypress (was Spansion) S25FL116K 2MiB SPI flash. +// Datasheet: http://www.cypress.com/file/196886/download +#define S25FL116K { \ + .total_size = (1 << 21), /* 2 MiB */ \ + .start_up_time_us = 10000, \ + .manufacturer_id = 0x01, \ + .memory_type = 0x40, \ + .capacity = 0x15, \ + .max_clock_speed_mhz = 108, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = false, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Cypress (was Spansion) S25FL216K 2MiB SPI flash. +// Datasheet: http://www.cypress.com/file/197346/download +#define S25FL216K { \ + .total_size = (1 << 21), /* 2 MiB */ \ + .start_up_time_us = 10000, \ + .manufacturer_id = 0x01, \ + .memory_type = 0x40, \ + .capacity = 0x15, \ + .max_clock_speed_mhz = 65, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = false, \ + .supports_qspi_writes = false, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Winbond W25Q16FW 2MiB SPI flash. +// Datasheet: https://www.winbond.com/resource-files/w25q16fw%20revj%2005182017%20sfdp.pdf +#define W25Q16FW { \ + .total_size = (1 << 21), /* 2 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x60, \ + .capacity = 0x15, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Winbond W25Q16JV-IQ 2MiB SPI flash. Note that JV-IM has a different .memory_type (0x70) +// Datasheet: https://www.winbond.com/resource-files/w25q16jv%20spi%20revf%2005092017.pdf +#define W25Q16JV_IQ { \ + .total_size = (1 << 21), /* 2 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x40, \ + .capacity = 0x15, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Winbond W25Q16JV-IM 2MiB SPI flash. Note that JV-IQ has a different .memory_type (0x40) +// Datasheet: https://www.winbond.com/resource-files/w25q16jv%20spi%20revf%2005092017.pdf +#define W25Q16JV_IM { \ + .total_size = (1 << 21), /* 2 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x70, \ + .capacity = 0x15, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ +} + +// Settings for the Winbond W25Q32BV 4MiB SPI flash. +// Datasheet: https://www.winbond.com/resource-files/w25q32bv_revi_100413_wo_automotive.pdf +#define W25Q32BV { \ + .total_size = (1 << 22), /* 4 MiB */ \ + .start_up_time_us = 10000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x60, \ + .capacity = 0x16, \ + .max_clock_speed_mhz = 104, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = false, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} +// Settings for the Winbond W25Q32JV-IM 4MiB SPI flash. +// Datasheet: https://www.winbond.com/resource-files/w25q32jv%20revg%2003272018%20plus.pdf +#define W25Q32JV_IM { \ + .total_size = (1 << 22), /* 4 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x70, \ + .capacity = 0x16, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ +} + +// Settings for the Winbond W25Q32JV-IM 4MiB SPI flash. +// Datasheet: https://www.winbond.com/resource-files/w25q32jv%20revg%2003272018%20plus.pdf +#define W25Q32JV_IQ { \ + .total_size = (1 << 22), /* 4 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x40, \ + .capacity = 0x16, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ +} + +// Settings for the Winbond W25Q64JV-IM 8MiB SPI flash. Note that JV-IQ has a different .memory_type (0x40) +// Datasheet: http://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf +#define W25Q64JV_IM { \ + .total_size = (1 << 23), /* 8 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x70, \ + .capacity = 0x17, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Winbond W25Q64JV-IQ 8MiB SPI flash. Note that JV-IM has a different .memory_type (0x70) +// Datasheet: http://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf +#define W25Q64JV_IQ { \ + .total_size = (1 << 23), /* 8 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x40, \ + .capacity = 0x17, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Winbond W25Q80DL 1MiB SPI flash. +// Datasheet: https://www.winbond.com/resource-files/w25q80dv%20dl_revh_10022015.pdf +#define W25Q80DL { \ + .total_size = (1 << 20), /* 1 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x60, \ + .capacity = 0x14, \ + .max_clock_speed_mhz = 104, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = false, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + + +// Settings for the Winbond W25Q128JV-SQ 16MiB SPI flash. Note that JV-IM has a different .memory_type (0x70) +// Datasheet: https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf +#define W25Q128JV_SQ { \ + .total_size = (1 << 24), /* 16 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x40, \ + .capacity = 0x18, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for the Macronix MX25L1606 2MiB SPI flash. +// Datasheet: +#define MX25L1606 { \ + .total_size = (1 << 21), /* 2 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xc2, \ + .memory_type = 0x20, \ + .capacity = 0x15, \ + .max_clock_speed_mhz = 8, \ + .quad_enable_bit_mask = 0x40, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = true, \ +} + +// Settings for the Macronix MX25L3233F 4MiB SPI flash. +// Datasheet: http://www.macronix.com/Lists/Datasheet/Attachments/7426/MX25L3233F,%203V,%2032Mb,%20v1.6.pdf +#define MX25L3233F { \ + .total_size = (1 << 22), /* 4 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xc2, \ + .memory_type = 0x20, \ + .capacity = 0x16, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x40, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = true, \ +} + +// Settings for the Macronix MX25R6435F 8MiB SPI flash. +// Datasheet: http://www.macronix.com/Lists/Datasheet/Attachments/7428/MX25R6435F,%20Wide%20Range,%2064Mb,%20v1.4.pdf +// By default its in lower power mode which can only do 8mhz. In high power mode it can do 80mhz. +#define MX25R6435F { \ + .total_size = (1 << 23), /* 8 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xc2, \ + .memory_type = 0x28, \ + .capacity = 0x17, \ + .max_clock_speed_mhz = 8, \ + .quad_enable_bit_mask = 0x40, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = true, \ +} + +// Settings for the Winbond W25Q128JV-PM 16MiB SPI flash. Note that JV-IM has a different .memory_type (0x70) +// Datasheet: https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf +#define W25Q128JV_PM { \ + .total_size = (1 << 24), /* 16 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x70, \ + .capacity = 0x18, \ + .max_clock_speed_mhz = 133, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ +} + +// Settings for the Winbond W25Q32FV 4MiB SPI flash. +// Datasheet:http://www.winbond.com/resource-files/w25q32fv%20revj%2006032016.pdf?__locale=en +#define W25Q32FV { \ + .total_size = (1 << 22), /* 4 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x40, \ + .capacity = 0x16, \ + .max_clock_speed_mhz = 104, \ + .quad_enable_bit_mask = 0x00, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = false, \ + .supports_qspi_writes = false, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + +// Settings for a GENERIC device with the most common setting +#define GENERIC { \ + .total_size = (1 << 21), /* 2 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0x00, \ + .memory_type = 0x40, \ + .capacity = 0x15, \ + .max_clock_speed_mhz = 48, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = true, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} +#endif // MICROPY_INCLUDED_ATMEL_SAMD_EXTERNAL_FLASH_DEVICES_H diff --git a/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.h b/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.h index b78c003b19a..a9f7d518e23 100644 --- a/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.h +++ b/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.h @@ -3,3 +3,5 @@ #define MICROPY_HW_XOSC32K (1) #define MICROPY_HW_MCU_OSC32KULP (1) + +#define MICROPY_HW_QSPIFLASH GD25Q16C diff --git a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.h b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.h index f53481d6319..2f246c60b18 100644 --- a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.h +++ b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.h @@ -2,3 +2,5 @@ #define MICROPY_HW_MCU_NAME "SAMD51G19A" #define MICROPY_HW_DFLL_USB_SYNC (1) + +#define MICROPY_HW_QSPIFLASH GD25Q16C diff --git a/ports/samd/boards/MINISAM_M4/mpconfigboard.h b/ports/samd/boards/MINISAM_M4/mpconfigboard.h index 6715a16f014..2dc403bad60 100644 --- a/ports/samd/boards/MINISAM_M4/mpconfigboard.h +++ b/ports/samd/boards/MINISAM_M4/mpconfigboard.h @@ -1,2 +1,4 @@ #define MICROPY_HW_BOARD_NAME "Mini SAM M4" #define MICROPY_HW_MCU_NAME "SAMD51G19A" + +#define MICROPY_HW_QSPIFLASH GD25Q16C diff --git a/ports/samd/boards/SEEED_WIO_TERMINAL/mpconfigboard.h b/ports/samd/boards/SEEED_WIO_TERMINAL/mpconfigboard.h index 8260992101c..062f69ae4e7 100644 --- a/ports/samd/boards/SEEED_WIO_TERMINAL/mpconfigboard.h +++ b/ports/samd/boards/SEEED_WIO_TERMINAL/mpconfigboard.h @@ -2,3 +2,5 @@ #define MICROPY_HW_MCU_NAME "SAMD51P19A" #define MICROPY_HW_XOSC32K (1) + +#define MICROPY_HW_QSPIFLASH W25Q32JV_IQ diff --git a/ports/samd/boards/SPARKFUN_SAMD51_THING_PLUS/mpconfigboard.h b/ports/samd/boards/SPARKFUN_SAMD51_THING_PLUS/mpconfigboard.h index a51b71c363e..706fc3c64c3 100644 --- a/ports/samd/boards/SPARKFUN_SAMD51_THING_PLUS/mpconfigboard.h +++ b/ports/samd/boards/SPARKFUN_SAMD51_THING_PLUS/mpconfigboard.h @@ -8,3 +8,8 @@ // 256k. Since the SAMD51x20A has 256k RAM, the loader symbol is at that address // and so there is a fix here using the previous definition. #define DBL_TAP_ADDR_ALT ((volatile uint32_t *)(HSRAM_ADDR + HSRAM_SIZE - 0x10000 - 4)) + +// Enabling both two lines below will set the boot file system to +// the board's external flash. +#define MICROPY_HW_SPIFLASH (1) +#define MICROPY_HW_SPIFLASH_ID (0) diff --git a/ports/samd/pin_af.h b/ports/samd/pin_af.h index edab72aaed6..3a15ae7f356 100644 --- a/ports/samd/pin_af.h +++ b/ports/samd/pin_af.h @@ -65,6 +65,9 @@ typedef struct _machine_pin_obj_t { #define ALT_FCT_TC 4 #define ALT_FCT_TCC1 5 #define ALT_FCT_TCC2 6 +#define ALT_FCT_QSPI 7 +#define ALT_FCT_CAN1 7 +#define ALT_FCT_USB 7 #endif diff --git a/ports/samd/samd_qspiflash.c b/ports/samd/samd_qspiflash.c new file mode 100644 index 00000000000..9bb79de5c5a --- /dev/null +++ b/ports/samd/samd_qspiflash.c @@ -0,0 +1,491 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Adafruit Industries + * Copyright (c) 2023 Robert Hammelrath + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Port of the Adafruit QSPIflash driver for SAMD devices + * + */ + +#include +#include +#include "py/obj.h" +#include "py/runtime.h" +#include "py/mphal.h" +#include "py/mperrno.h" +#include "modmachine.h" +#include "extmod/machine_spi.h" +#include "extmod/vfs.h" +#include "pin_af.h" +#include "clock_config.h" +#include "sam.h" + +#ifdef MICROPY_HW_QSPIFLASH + +#include "drivers/memory/external_flash_device.h" + +// QSPI command codes +enum +{ + QSPI_CMD_READ = 0x03, + QSPI_CMD_READ_4B = 0x13, + QSPI_CMD_QUAD_READ = 0x6B,// 1 line address, 4 line data + + QSPI_CMD_READ_JEDEC_ID = 0x9f, + + QSPI_CMD_PAGE_PROGRAM = 0x02, + QSPI_CMD_PAGE_PROGRAM_4B = 0x12, + QSPI_CMD_QUAD_PAGE_PROGRAM = 0x32, // 1 line address, 4 line data + + QSPI_CMD_READ_STATUS = 0x05, + QSPI_CMD_READ_STATUS2 = 0x35, + + QSPI_CMD_WRITE_STATUS = 0x01, + QSPI_CMD_WRITE_STATUS2 = 0x31, + + QSPI_CMD_ENABLE_RESET = 0x66, + QSPI_CMD_RESET = 0x99, + + QSPI_CMD_WRITE_ENABLE = 0x06, + QSPI_CMD_WRITE_DISABLE = 0x04, + + QSPI_CMD_ERASE_SECTOR = 0x20, + QSPI_CMD_ERASE_SECTOR_4B = 0x21, + QSPI_CMD_ERASE_BLOCK = 0xD8, + QSPI_CMD_ERASE_CHIP = 0xC7, + + QSPI_CMD_READ_SFDP_PARAMETER = 0x5A, +}; + +// QSPI flash pins are: CS=PB11, SCK=PB10, IO0-IO3=PA08, PA09, PA10 and PA11. +#define PIN_CS (43) +#define PIN_SCK (42) +#define PIN_IO0 (8) +#define PIN_IO1 (9) +#define PIN_IO2 (10) +#define PIN_IO3 (11) + +#define PAGE_SIZE (256) +#define SECTOR_SIZE (4096) + +typedef struct _samd_qspiflash_obj_t { + mp_obj_base_t base; + uint16_t pagesize; + uint16_t sectorsize; + uint32_t size; + uint8_t phase; + uint8_t polarity; +} samd_qspiflash_obj_t; + +/// List of all possible flash devices used by Adafruit boards +static const external_flash_device possible_devices[] = { + MICROPY_HW_QSPIFLASH +}; + +#define EXTERNAL_FLASH_DEVICE_COUNT MP_ARRAY_SIZE(possible_devices) +static external_flash_device const *flash_device; +static external_flash_device generic_config = GENERIC; +extern const mp_obj_type_t samd_qspiflash_type; + +// The QSPIflash object is a singleton +static samd_qspiflash_obj_t qspiflash_obj = { { &samd_qspiflash_type } }; + +// Turn off cache and invalidate all data in it. +static void samd_peripherals_disable_and_clear_cache(void) { + CMCC->CTRL.bit.CEN = 0; + while (CMCC->SR.bit.CSTS) { + } + CMCC->MAINT0.bit.INVALL = 1; +} + +// Enable cache +static void samd_peripherals_enable_cache(void) { + CMCC->CTRL.bit.CEN = 1; +} + +// Run a single QSPI instruction. +// Parameters are: +// - command instruction code +// - iframe iframe register value (configured by caller according to command code) +// - addr the address to read or write from. If the instruction doesn't require an address, this parameter is meaningless. +// - buffer pointer to the data to be written or stored depending on the type is Read or Write +// - size the number of bytes to read or write. +bool run_instruction(uint8_t command, uint32_t iframe, uint32_t addr, uint8_t *buffer, uint32_t size) { + + samd_peripherals_disable_and_clear_cache(); + + uint8_t *qspi_mem = (uint8_t *)QSPI_AHB; + if (addr) { + qspi_mem += addr; + } + + QSPI->INSTRCTRL.bit.INSTR = command; + QSPI->INSTRADDR.reg = addr; + QSPI->INSTRFRAME.reg = iframe; + + // Dummy read of INSTRFRAME needed to synchronize. + // See Instruction Transmission Flow Diagram, figure 37.9, page 995 + // and Example 4, page 998, section 37.6.8.5. + (volatile uint32_t)QSPI->INSTRFRAME.reg; + + if (buffer && size) { + uint32_t const tfr_type = iframe & QSPI_INSTRFRAME_TFRTYPE_Msk; + if ((tfr_type == QSPI_INSTRFRAME_TFRTYPE_READ) || (tfr_type == QSPI_INSTRFRAME_TFRTYPE_READMEMORY)) { + memcpy(buffer, qspi_mem, size); + } else { + memcpy(qspi_mem, buffer, size); + } + } + + __asm volatile ("dsb"); + __asm volatile ("isb"); + + QSPI->CTRLA.reg = QSPI_CTRLA_ENABLE | QSPI_CTRLA_LASTXFER; + while (!QSPI->INTFLAG.bit.INSTREND) { + } + QSPI->INTFLAG.reg = QSPI_INTFLAG_INSTREND; + + samd_peripherals_enable_cache(); + return true; +} + +bool run_command(uint8_t command) { + uint32_t iframe = QSPI_INSTRFRAME_WIDTH_SINGLE_BIT_SPI | QSPI_INSTRFRAME_ADDRLEN_24BITS | + QSPI_INSTRFRAME_TFRTYPE_READ | QSPI_INSTRFRAME_INSTREN; + return run_instruction(command, iframe, 0, NULL, 0); +} + +bool read_command(uint8_t command, uint8_t *response, uint32_t len) { + uint32_t iframe = QSPI_INSTRFRAME_WIDTH_SINGLE_BIT_SPI | QSPI_INSTRFRAME_ADDRLEN_24BITS | + QSPI_INSTRFRAME_TFRTYPE_READ | QSPI_INSTRFRAME_INSTREN | QSPI_INSTRFRAME_DATAEN; + return run_instruction(command, iframe, 0, response, len); +} + +bool read_memory_single(uint8_t command, uint32_t addr, uint8_t *response, uint32_t len) { + uint32_t iframe = QSPI_INSTRFRAME_WIDTH_SINGLE_BIT_SPI | QSPI_INSTRFRAME_ADDRLEN_24BITS | + QSPI_INSTRFRAME_TFRTYPE_READ | QSPI_INSTRFRAME_INSTREN | QSPI_INSTRFRAME_ADDREN | + QSPI_INSTRFRAME_DATAEN | QSPI_INSTRFRAME_DUMMYLEN(8); + return run_instruction(command, iframe, addr, response, len); +} + +bool write_command(uint8_t command, uint8_t const *data, uint32_t len) { + uint32_t iframe = QSPI_INSTRFRAME_WIDTH_SINGLE_BIT_SPI | QSPI_INSTRFRAME_ADDRLEN_24BITS | + QSPI_INSTRFRAME_TFRTYPE_WRITE | QSPI_INSTRFRAME_INSTREN | (data != NULL ? QSPI_INSTRFRAME_DATAEN : 0); + return run_instruction(command, iframe, 0, (uint8_t *)data, len); +} + +bool erase_command(uint8_t command, uint32_t address) { + // Sector Erase + uint32_t iframe = QSPI_INSTRFRAME_WIDTH_SINGLE_BIT_SPI | QSPI_INSTRFRAME_ADDRLEN_24BITS | + QSPI_INSTRFRAME_TFRTYPE_WRITE | QSPI_INSTRFRAME_INSTREN | QSPI_INSTRFRAME_ADDREN; + return run_instruction(command, iframe, address, NULL, 0); +} + +bool read_memory_quad(uint8_t command, uint32_t addr, uint8_t *data, uint32_t len) { + uint32_t iframe = QSPI_INSTRFRAME_WIDTH_QUAD_OUTPUT | QSPI_INSTRFRAME_ADDRLEN_24BITS | + QSPI_INSTRFRAME_TFRTYPE_READMEMORY | QSPI_INSTRFRAME_INSTREN | QSPI_INSTRFRAME_ADDREN | QSPI_INSTRFRAME_DATAEN | + /*QSPI_INSTRFRAME_CRMODE |*/ QSPI_INSTRFRAME_DUMMYLEN(8); + return run_instruction(command, iframe, addr, data, len); +} + +bool write_memory_quad(uint8_t command, uint32_t addr, uint8_t *data, uint32_t len) { + uint32_t iframe = QSPI_INSTRFRAME_WIDTH_QUAD_OUTPUT | QSPI_INSTRFRAME_ADDRLEN_24BITS | + QSPI_INSTRFRAME_TFRTYPE_WRITEMEMORY | QSPI_INSTRFRAME_INSTREN | QSPI_INSTRFRAME_ADDREN | QSPI_INSTRFRAME_DATAEN; + return run_instruction(command, iframe, addr, data, len); +} + +static uint8_t read_status(void) { + uint8_t r; + read_command(QSPI_CMD_READ_STATUS, &r, 1); + return r; +} + +static uint8_t read_status2(void) { + uint8_t r; + read_command(QSPI_CMD_READ_STATUS2, &r, 1); + return r; +} + +static bool write_enable(void) { + return run_command(QSPI_CMD_WRITE_ENABLE); +} + +static void wait_for_flash_ready(void) { + // both WIP and WREN bit should be clear + while (read_status() & 0x03) { + } +} + +static uint8_t get_baud(int32_t freq_mhz) { + int baud = get_peripheral_freq() / (freq_mhz * 1000000) - 1; + if (baud < 1) { + baud = 1; + } + if (baud > 255) { + baud = 255; + } + return baud; +} + +int get_sfdp_table(uint8_t *table, int maxlen) { + uint8_t header[16]; + read_memory_single(QSPI_CMD_READ_SFDP_PARAMETER, 0, header, sizeof(header)); + int len = MIN(header[11] * 4, maxlen); + int addr = header[12] + (header[13] << 8) + (header[14] << 16); + read_memory_single(QSPI_CMD_READ_SFDP_PARAMETER, addr, table, len); + return len; +} + +STATIC mp_obj_t samd_qspiflash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + mp_arg_check_num(n_args, n_kw, 0, 0, false); + + // The QSPI is a singleton + samd_qspiflash_obj_t *self = &qspiflash_obj; + self->phase = 0; + self->polarity = 0; + self->pagesize = PAGE_SIZE; + self->sectorsize = SECTOR_SIZE; + + // Enable the device clock + MCLK->AHBMASK.reg |= MCLK_AHBMASK_QSPI; + MCLK->AHBMASK.reg |= MCLK_AHBMASK_QSPI_2X; + MCLK->APBCMASK.reg |= MCLK_APBCMASK_QSPI; + + // Configure the pins. + mp_hal_set_pin_mux(PIN_CS, ALT_FCT_QSPI); + mp_hal_set_pin_mux(PIN_SCK, ALT_FCT_QSPI); + mp_hal_set_pin_mux(PIN_IO0, ALT_FCT_QSPI); + mp_hal_set_pin_mux(PIN_IO1, ALT_FCT_QSPI); + mp_hal_set_pin_mux(PIN_IO2, ALT_FCT_QSPI); + mp_hal_set_pin_mux(PIN_IO3, ALT_FCT_QSPI); + + // Configure the QSPI interface + QSPI->CTRLA.bit.SWRST = 1; + mp_hal_delay_us(1000); // Maybe not required. + + QSPI->CTRLB.reg = QSPI_CTRLB_MODE_MEMORY | + QSPI_CTRLB_CSMODE_NORELOAD | + QSPI_CTRLB_DATALEN_8BITS | + QSPI_CTRLB_CSMODE_LASTXFER; + // start with low 4Mhz, Mode 0 + QSPI->BAUD.reg = QSPI_BAUD_BAUD(get_baud(4)) | + (self->phase << QSPI_BAUD_CPHA_Pos) | + (self->polarity << QSPI_BAUD_CPOL_Pos); + QSPI->CTRLA.bit.ENABLE = 1; + + uint8_t jedec_ids[3]; + read_command(QSPI_CMD_READ_JEDEC_ID, jedec_ids, sizeof(jedec_ids)); + + // Read the common sfdp table + // Check the device addr length, support of 1-1-4 mode and get the sector size + uint8_t sfdp_table[128]; + int len = get_sfdp_table(sfdp_table, sizeof(sfdp_table)); + if (len >= 29) { + self->sectorsize = 1 << sfdp_table[28]; + bool addr4b = ((sfdp_table[2] >> 1) & 0x03) == 0x02; + bool supports_qspi_114 = (sfdp_table[2] & 0x40) != 0; + if (addr4b || !supports_qspi_114) { + mp_raise_ValueError(MP_ERROR_TEXT("QSPI mode not supported")); + } + } + + // Check, if the flash device is known and get it's properties. + flash_device = NULL; + for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) { + const external_flash_device *possible_device = &possible_devices[i]; + if (jedec_ids[0] == possible_device->manufacturer_id && + jedec_ids[1] == possible_device->memory_type && + jedec_ids[2] == possible_device->capacity) { + flash_device = possible_device; + break; + } + } + + // If the flash device is not known, try generic config options + if (flash_device == NULL) { + if (jedec_ids[0] == 0xc2) { // Macronix devices + generic_config.quad_enable_bit_mask = 0x04; + generic_config.single_status_byte = true; + } + generic_config.total_size = 1 << jedec_ids[2]; + flash_device = &generic_config; + } + + self->size = flash_device->total_size; + + // The write in progress bit should be low. + while (read_status() & 0x01) { + } + // The suspended write/erase bit should be low. + while (read_status2() & 0x80) { + } + run_command(QSPI_CMD_ENABLE_RESET); + run_command(QSPI_CMD_RESET); + // Wait 30us for the reset + mp_hal_delay_us(30); + // Speed up the frequency + QSPI->BAUD.bit.BAUD = get_baud(flash_device->max_clock_speed_mhz); + + // Enable Quad Mode if available + uint8_t status = 0; + if (flash_device->quad_enable_bit_mask) { + // Verify that QSPI mode is enabled. + status = flash_device->single_status_byte ? read_status() : read_status2(); + } + + // Check the quad enable bit. + if ((status & flash_device->quad_enable_bit_mask) == 0) { + write_enable(); + uint8_t full_status[2] = {0x00, flash_device->quad_enable_bit_mask}; + + if (flash_device->write_status_register_split) { + write_command(QSPI_CMD_WRITE_STATUS2, full_status + 1, 1); + } else if (flash_device->single_status_byte) { + write_command(QSPI_CMD_WRITE_STATUS, full_status + 1, 1); + } else { + write_command(QSPI_CMD_WRITE_STATUS, full_status, 2); + } + } + // Turn off writes in case this is a microcontroller only reset. + run_command(QSPI_CMD_WRITE_DISABLE); + wait_for_flash_ready(); + + return self; +} + +STATIC mp_obj_t samd_qspiflash_read(samd_qspiflash_obj_t *self, uint32_t addr, uint8_t *dest, uint32_t len) { + if (len > 0) { + wait_for_flash_ready(); + // Command 0x6B 1 line address, 4 line Data + // with Continuous Read Mode and Quad output mode, read memory type + read_memory_quad(QSPI_CMD_QUAD_READ, addr, dest, len); + } + + return mp_const_none; +} + +STATIC mp_obj_t samd_qspiflash_write(samd_qspiflash_obj_t *self, uint32_t addr, uint8_t *src, uint32_t len) { + uint32_t length = len; + uint32_t pos = 0; + uint8_t *buf = src; + + while (pos < length) { + uint16_t maxsize = self->pagesize - pos % self->pagesize; + uint16_t size = (length - pos) > maxsize ? maxsize : length - pos; + + wait_for_flash_ready(); + write_enable(); + write_memory_quad(QSPI_CMD_QUAD_PAGE_PROGRAM, addr, buf + pos, size); + + addr += size; + pos += size; + } + + return mp_const_none; +} + +STATIC mp_obj_t samd_qspiflash_erase(uint32_t addr) { + wait_for_flash_ready(); + write_enable(); + erase_command(QSPI_CMD_ERASE_SECTOR, addr); + + return mp_const_none; +} + +STATIC mp_obj_t samd_qspiflash_readblocks(size_t n_args, const mp_obj_t *args) { + samd_qspiflash_obj_t *self = MP_OBJ_TO_PTR(args[0]); + uint32_t offset = (mp_obj_get_int(args[1]) * self->sectorsize); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE); + if (n_args == 4) { + offset += mp_obj_get_int(args[3]); + } + + // Read data to flash (adf4 API) + samd_qspiflash_read(self, offset, bufinfo.buf, bufinfo.len); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(samd_qspiflash_readblocks_obj, 3, 4, samd_qspiflash_readblocks); + +STATIC mp_obj_t samd_qspiflash_writeblocks(size_t n_args, const mp_obj_t *args) { + samd_qspiflash_obj_t *self = MP_OBJ_TO_PTR(args[0]); + uint32_t offset = (mp_obj_get_int(args[1]) * self->sectorsize); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); + if (n_args == 3) { + samd_qspiflash_erase(offset); + // TODO check return value + } else { + offset += mp_obj_get_int(args[3]); + } + // Write data to flash (adf4 API) + samd_qspiflash_write(self, offset, bufinfo.buf, bufinfo.len); + // TODO check return value + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(samd_qspiflash_writeblocks_obj, 3, 4, samd_qspiflash_writeblocks); + +STATIC mp_obj_t samd_qspiflash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg_in) { + samd_qspiflash_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t cmd = mp_obj_get_int(cmd_in); + + switch (cmd) { + case MP_BLOCKDEV_IOCTL_INIT: + return MP_OBJ_NEW_SMALL_INT(0); + case MP_BLOCKDEV_IOCTL_DEINIT: + return MP_OBJ_NEW_SMALL_INT(0); + case MP_BLOCKDEV_IOCTL_SYNC: + return MP_OBJ_NEW_SMALL_INT(0); + case MP_BLOCKDEV_IOCTL_BLOCK_COUNT: + return MP_OBJ_NEW_SMALL_INT(self->size / self->sectorsize); + case MP_BLOCKDEV_IOCTL_BLOCK_SIZE: + return MP_OBJ_NEW_SMALL_INT(self->sectorsize); + case MP_BLOCKDEV_IOCTL_BLOCK_ERASE: { + samd_qspiflash_erase(mp_obj_get_int(arg_in) * self->sectorsize); + // TODO check return value + return MP_OBJ_NEW_SMALL_INT(0); + } + default: + return mp_const_none; + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(samd_qspiflash_ioctl_obj, samd_qspiflash_ioctl); + +STATIC const mp_rom_map_elem_t samd_qspiflash_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_readblocks), MP_ROM_PTR(&samd_qspiflash_readblocks_obj) }, + { MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&samd_qspiflash_writeblocks_obj) }, + { MP_ROM_QSTR(MP_QSTR_ioctl), MP_ROM_PTR(&samd_qspiflash_ioctl_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(samd_qspiflash_locals_dict, samd_qspiflash_locals_dict_table); + +MP_DEFINE_CONST_OBJ_TYPE( + samd_qspiflash_type, + MP_QSTR_Flash, + MP_TYPE_FLAG_NONE, + make_new, samd_qspiflash_make_new, + locals_dict, &samd_qspiflash_locals_dict + ); + +#endif // MICROPY_HW_QSPI_FLASH From 69cb5e8f2ac6ffd1b4e2127eb31321bff240a654 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Wed, 24 May 2023 16:19:33 +0200 Subject: [PATCH 0005/4300] samd: Adapt existing samd.Flash and integrate with (Q)SPI flash in boot. Checks are added to ensure, that only one of the flash drivers is selected. Signed-off-by: robert-hh --- ports/samd/Makefile | 2 ++ ports/samd/modsamd.c | 13 ++++++++++++- ports/samd/modules/_boot.py | 10 +++++----- ports/samd/mpconfigport.h | 5 +++++ ports/samd/samd_flash.c | 38 +++++++++++++++---------------------- 5 files changed, 39 insertions(+), 29 deletions(-) diff --git a/ports/samd/Makefile b/ports/samd/Makefile index 6f7c8fbd85a..211607650ba 100644 --- a/ports/samd/Makefile +++ b/ports/samd/Makefile @@ -113,7 +113,9 @@ SRC_C += \ pin_af.c \ samd_flash.c \ samd_isr.c \ + samd_qspiflash.c \ samd_soc.c \ + samd_spiflash.c \ tusb_port.c \ SHARED_SRC_C += \ diff --git a/ports/samd/modsamd.c b/ports/samd/modsamd.c index 7593a7bb0da..307de62af56 100644 --- a/ports/samd/modsamd.c +++ b/ports/samd/modsamd.c @@ -32,7 +32,18 @@ #include "pin_af.h" #include "samd_soc.h" +#if MICROPY_HW_MCUFLASH extern const mp_obj_type_t samd_flash_type; +#define SPIFLASH_TYPE samd_flash_type +#endif +#ifdef MICROPY_HW_QSPIFLASH +extern const mp_obj_type_t samd_qspiflash_type; +#define SPIFLASH_TYPE samd_qspiflash_type +#endif +#if MICROPY_HW_SPIFLASH +extern const mp_obj_type_t samd_spiflash_type; +#define SPIFLASH_TYPE samd_spiflash_type +#endif STATIC mp_obj_t samd_pininfo(mp_obj_t pin_obj) { const machine_pin_obj_t *pin_af = pin_find(pin_obj); @@ -67,7 +78,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(samd_pininfo_obj, samd_pininfo); STATIC const mp_rom_map_elem_t samd_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_samd) }, - { MP_ROM_QSTR(MP_QSTR_Flash), MP_ROM_PTR(&samd_flash_type) }, + { MP_ROM_QSTR(MP_QSTR_Flash), MP_ROM_PTR(&SPIFLASH_TYPE) }, { MP_ROM_QSTR(MP_QSTR_pininfo), MP_ROM_PTR(&samd_pininfo_obj) }, }; STATIC MP_DEFINE_CONST_DICT(samd_module_globals, samd_module_globals_table); diff --git a/ports/samd/modules/_boot.py b/ports/samd/modules/_boot.py index e183125f2e4..5fe2bc640c5 100644 --- a/ports/samd/modules/_boot.py +++ b/ports/samd/modules/_boot.py @@ -2,18 +2,18 @@ import uos import samd -samd.Flash.flash_init() bdev = samd.Flash() # Try to mount the filesystem, and format the flash if it doesn't exist. fs_type = uos.VfsLfs2 if hasattr(uos, "VfsLfs2") else uos.VfsLfs1 try: - vfs = fs_type(bdev) + vfs = fs_type(bdev, progsize=256) except: - fs_type.mkfs(bdev) - vfs = fs_type(bdev) + fs_type.mkfs(bdev, progsize=256) + vfs = fs_type(bdev, progsize=256) uos.mount(vfs, "/") +del vfs, fs_type, bdev, uos, samd gc.collect() -del uos, vfs, gc +del gc diff --git a/ports/samd/mpconfigport.h b/ports/samd/mpconfigport.h index bf03b5f7bd6..7392b030590 100644 --- a/ports/samd/mpconfigport.h +++ b/ports/samd/mpconfigport.h @@ -136,6 +136,11 @@ #define MICROPY_BOARD_PENDSV_ENTRIES #endif +// Use internal flash for the file system if no flash file system is selected. +#if !defined(MICROPY_HW_MCUFLASH) && !defined(MICROPY_HW_QSPIFLASH) && !(defined(MICROPY_HW_SPIFLASH) && defined(MICROPY_HW_SPIFLASH_ID)) +#define MICROPY_HW_MCUFLASH (1) +#endif // !defined(MICROPY_HW_MCUFLASH) .... + // Miscellaneous settings __attribute__((always_inline)) static inline void enable_irq(uint32_t state) { __set_PRIMASK(state); diff --git a/ports/samd/samd_flash.c b/ports/samd/samd_flash.c index 6d9ee96895b..b00b4af6032 100644 --- a/ports/samd/samd_flash.c +++ b/ports/samd/samd_flash.c @@ -29,7 +29,8 @@ #include "py/runtime.h" #include "extmod/vfs.h" #include "samd_soc.h" -#include "hal_flash.h" + +#if MICROPY_HW_MCUFLASH // ASF 4 #include "hal_flash.h" @@ -62,18 +63,9 @@ STATIC samd_flash_obj_t samd_flash_obj = { .flash_size = (uint32_t)&_sflash_fs, // Get from MCU-Specific loader script. }; -// FLASH stuff -STATIC mp_obj_t samd_flash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - // No args required. bdev=Flash(). Start Addr & Size defined in samd_flash_obj. - mp_arg_check_num(n_args, n_kw, 0, 0, false); - - // Return singleton object. - return MP_OBJ_FROM_PTR(&samd_flash_obj); -} - // Flash init (from cctpy) // Method is needed for when MP starts up in _boot.py -STATIC mp_obj_t samd_flash_init(void) { +STATIC void samd_flash_init(void) { #ifdef SAMD51 hri_mclk_set_AHBMASK_NVMCTRL_bit(MCLK); #endif @@ -82,9 +74,17 @@ STATIC mp_obj_t samd_flash_init(void) { #endif flash_init(&flash_desc, NVMCTRL); - return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_0(samd_flash_init_obj, samd_flash_init); + +STATIC mp_obj_t samd_flash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + // No args required. bdev=Flash(). Start Addr & Size defined in samd_flash_obj. + mp_arg_check_num(n_args, n_kw, 0, 0, false); + + samd_flash_init(); + + // Return singleton object. + return MP_OBJ_FROM_PTR(&samd_flash_obj); +} // Function for ioctl. STATIC mp_obj_t eraseblock(uint32_t sector_in) { @@ -102,14 +102,6 @@ STATIC mp_obj_t samd_flash_version(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(samd_flash_version_obj, samd_flash_version); -STATIC mp_obj_t samd_flash_size(void) { - // ASF4 API calls - mp_int_t PAGES = flash_get_total_pages(&flash_desc); - mp_int_t PAGE_SIZE = flash_get_page_size(&flash_desc); - return MP_OBJ_NEW_SMALL_INT(PAGES * PAGE_SIZE); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(samd_flash_size_obj, samd_flash_size); - STATIC mp_obj_t samd_flash_readblocks(size_t n_args, const mp_obj_t *args) { uint32_t offset = (mp_obj_get_int(args[1]) * BLOCK_SIZE) + samd_flash_obj.flash_base; mp_buffer_info_t bufinfo; @@ -171,8 +163,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(samd_flash_ioctl_obj, samd_flash_ioctl); STATIC const mp_rom_map_elem_t samd_flash_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_flash_version), MP_ROM_PTR(&samd_flash_version_obj) }, - { MP_ROM_QSTR(MP_QSTR_flash_size), MP_ROM_PTR(&samd_flash_size_obj) }, - { MP_ROM_QSTR(MP_QSTR_flash_init), MP_ROM_PTR(&samd_flash_init_obj) }, { MP_ROM_QSTR(MP_QSTR_readblocks), MP_ROM_PTR(&samd_flash_readblocks_obj) }, { MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&samd_flash_writeblocks_obj) }, { MP_ROM_QSTR(MP_QSTR_ioctl), MP_ROM_PTR(&samd_flash_ioctl_obj) }, @@ -186,3 +176,5 @@ MP_DEFINE_CONST_OBJ_TYPE( make_new, samd_flash_make_new, locals_dict, &samd_flash_locals_dict ); + +#endif // MICROPY_HW_MCUFLASH From db5444f68aaca1bec2c90df0ed5afe36bce94cfc Mon Sep 17 00:00:00 2001 From: robert-hh Date: Wed, 24 May 2023 16:21:35 +0200 Subject: [PATCH 0006/4300] samd/boards: Extend the code size limit for boards with external flash. Code size limits are charged to: - SAMD21: 184K -> 248K - SAMD51x19: 368K -> 496K - SAMD51x20: 368K -> 1008K Signed-off-by: robert-hh --- ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.mk | 1 + ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.mk | 1 + ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.mk | 1 + ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.mk | 1 + ports/samd/boards/ADAFRUIT_METRO_M4_EXPRESS/mpconfigboard.mk | 1 + ports/samd/boards/MINISAM_M4/mpconfigboard.mk | 1 + ports/samd/boards/SEEED_WIO_TERMINAL/mpconfigboard.mk | 1 + ports/samd/boards/SPARKFUN_SAMD51_THING_PLUS/mpconfigboard.mk | 1 + 8 files changed, 8 insertions(+) diff --git a/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.mk b/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.mk index a760cf047e6..aa3fbd35dac 100644 --- a/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.mk +++ b/ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.mk @@ -6,3 +6,4 @@ TEXT0 = 0x2000 # The ?='s allow overriding in mpconfigboard.mk. # MicroPython settings MICROPY_VFS_LFS1 ?= 1 +MICROPY_HW_CODESIZE ?= 248K diff --git a/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.mk b/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.mk index 781faa24106..70d73ee6fa1 100644 --- a/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.mk +++ b/ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.mk @@ -6,3 +6,4 @@ TEXT0 = 0x4000 # The ?='s allow overriding in mpconfigboard.mk. # MicroPython settings MICROPY_VFS_LFS1 ?= 1 +MICROPY_HW_CODESIZE ?= 496K diff --git a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.mk b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.mk index a760cf047e6..aa3fbd35dac 100644 --- a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.mk +++ b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.mk @@ -6,3 +6,4 @@ TEXT0 = 0x2000 # The ?='s allow overriding in mpconfigboard.mk. # MicroPython settings MICROPY_VFS_LFS1 ?= 1 +MICROPY_HW_CODESIZE ?= 248K diff --git a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.mk b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.mk index da3e47589ad..7ef411431d7 100644 --- a/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.mk +++ b/ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.mk @@ -6,3 +6,4 @@ TEXT0 = 0x4000 # The ?='s allow overriding in mpconfigboard.mk. # MicroPython settings MICROPY_VFS_LFS1 ?= 1 +MICROPY_HW_CODESIZE ?= 496K diff --git a/ports/samd/boards/ADAFRUIT_METRO_M4_EXPRESS/mpconfigboard.mk b/ports/samd/boards/ADAFRUIT_METRO_M4_EXPRESS/mpconfigboard.mk index 238ca0055d6..a196612539c 100644 --- a/ports/samd/boards/ADAFRUIT_METRO_M4_EXPRESS/mpconfigboard.mk +++ b/ports/samd/boards/ADAFRUIT_METRO_M4_EXPRESS/mpconfigboard.mk @@ -10,3 +10,4 @@ MICROPY_PY_NETWORK ?= 1 MICROPY_PY_NETWORK_NINAW10 ?= 1 BOARD_VARIANTS += "wlan" +MICROPY_HW_CODESIZE ?= 496K diff --git a/ports/samd/boards/MINISAM_M4/mpconfigboard.mk b/ports/samd/boards/MINISAM_M4/mpconfigboard.mk index 73afb021044..4ccbf92c7e7 100644 --- a/ports/samd/boards/MINISAM_M4/mpconfigboard.mk +++ b/ports/samd/boards/MINISAM_M4/mpconfigboard.mk @@ -7,3 +7,4 @@ TEXT0 = 0x4000 # The ?='s allow overriding in mpconfigboard.mk. # MicroPython settings MICROPY_VFS_LFS1 ?= 1 +MICROPY_HW_CODESIZE ?= 496K diff --git a/ports/samd/boards/SEEED_WIO_TERMINAL/mpconfigboard.mk b/ports/samd/boards/SEEED_WIO_TERMINAL/mpconfigboard.mk index c2c4da61527..03f97e138c5 100644 --- a/ports/samd/boards/SEEED_WIO_TERMINAL/mpconfigboard.mk +++ b/ports/samd/boards/SEEED_WIO_TERMINAL/mpconfigboard.mk @@ -6,3 +6,4 @@ TEXT0 = 0x4000 # The ?='s allow overriding in mpconfigboard.mk. # MicroPython settings MICROPY_VFS_LFS1 ?= 1 +MICROPY_HW_CODESIZE ?= 496K diff --git a/ports/samd/boards/SPARKFUN_SAMD51_THING_PLUS/mpconfigboard.mk b/ports/samd/boards/SPARKFUN_SAMD51_THING_PLUS/mpconfigboard.mk index 9e5cf887dfc..65b1ba7a33d 100644 --- a/ports/samd/boards/SPARKFUN_SAMD51_THING_PLUS/mpconfigboard.mk +++ b/ports/samd/boards/SPARKFUN_SAMD51_THING_PLUS/mpconfigboard.mk @@ -6,3 +6,4 @@ TEXT0 = 0x4000 # The ?='s allow overriding in mpconfigboard.mk. # MicroPython settings MICROPY_VFS_LFS1 ?= 1 +MICROPY_HW_CODESIZE ?= 1008K From d080d427ebcc263ac6ff792271cec1506e5c81fc Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 2 Jun 2023 13:21:39 -0400 Subject: [PATCH 0007/4300] top: Add "mis" to list of ignore words for codespell. Observed with codespell 2.2.5.dev57+gdc7e98d9: $ codespell ./ports/rp2/machine_uart.c:163: mis ==> miss, mist ./ports/rp2/machine_uart.c:168: mis ==> miss, mist 2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a52796860ae..dfd26bd8c9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ line-length = 99 [tool.codespell] count = "" ignore-regex = '\b[A-Z]{3}\b' -ignore-words-list = "ans,asend,deques,dout,extint,hsi,iput,numer,technic,ure" +ignore-words-list = "ans,asend,deques,dout,extint,hsi,iput,mis,numer,technic,ure" quiet-level = 3 skip = """ */build*,\ From 30628d1bb782006c88325a086ddfcd5c2e5ddbb4 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Wed, 17 Aug 2022 16:18:31 +1000 Subject: [PATCH 0008/4300] all: Rename MP_QSTR_umodule to MP_QSTR_module everywhere. This renames the builtin-modules, such that help('modules') and printing the module object will show "module" rather than "umodule". This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- examples/natmod/uheapq/uheapq.c | 2 +- examples/natmod/urandom/urandom.c | 2 +- examples/natmod/ure/ure.c | 2 +- examples/natmod/uzlib/uzlib.c | 2 +- extmod/modbluetooth.c | 4 ++-- extmod/modlwip.c | 2 +- extmod/modubinascii.c | 4 ++-- extmod/moducryptolib.c | 4 ++-- extmod/moduhashlib.c | 4 ++-- extmod/moduheapq.c | 4 ++-- extmod/modujson.c | 4 ++-- extmod/moduos.c | 6 +++--- extmod/moduplatform.c | 4 ++-- extmod/modurandom.c | 4 ++-- extmod/modure.c | 6 +++--- extmod/moduselect.c | 4 ++-- extmod/modusocket.c | 4 ++-- extmod/modussl_axtls.c | 8 ++++---- extmod/modussl_mbedtls.c | 8 ++++---- extmod/modutime.c | 4 ++-- extmod/modutimeq.c | 8 ++++---- extmod/moduwebsocket.c | 4 ++-- extmod/moduzlib.c | 4 ++-- ports/cc3200/mods/modmachine.c | 4 ++-- ports/cc3200/mods/moduhashlib.c | 2 +- ports/cc3200/mods/moduos.c | 4 ++-- ports/cc3200/mods/modusocket.c | 4 ++-- ports/cc3200/mods/modussl.c | 6 +++--- ports/cc3200/mpconfigport.h | 2 +- ports/esp32/modmachine.c | 4 ++-- ports/esp32/modsocket.c | 4 ++-- ports/esp8266/modmachine.c | 4 ++-- ports/mimxrt/modmachine.c | 4 ++-- ports/nrf/modules/machine/modmachine.c | 4 ++-- ports/nrf/modules/uos/moduos.c | 4 ++-- ports/qemu-arm/modmachine.c | 4 ++-- ports/renesas-ra/README.md | 4 ++-- ports/renesas-ra/modmachine.c | 4 ++-- ports/renesas-ra/mpconfigport.h | 2 +- ports/rp2/README.md | 4 ++-- ports/rp2/modmachine.c | 4 ++-- ports/samd/modmachine.c | 4 ++-- ports/stm32/modmachine.c | 4 ++-- ports/stm32/mpconfigport.h | 2 +- ports/unix/modmachine.c | 4 ++-- ports/unix/moduselect.c | 4 ++-- ports/unix/modusocket.c | 4 ++-- ports/zephyr/README.md | 4 ++-- ports/zephyr/modmachine.c | 4 ++-- ports/zephyr/modusocket.c | 4 ++-- py/modarray.c | 4 ++-- py/modcollections.c | 4 ++-- py/modio.c | 4 ++-- py/modstruct.c | 4 ++-- py/modsys.c | 2 +- py/moduerrno.c | 4 ++-- 56 files changed, 111 insertions(+), 111 deletions(-) diff --git a/examples/natmod/uheapq/uheapq.c b/examples/natmod/uheapq/uheapq.c index 9da6bb4ada4..75f00e15cb0 100644 --- a/examples/natmod/uheapq/uheapq.c +++ b/examples/natmod/uheapq/uheapq.c @@ -7,7 +7,7 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) { MP_DYNRUNTIME_INIT_ENTRY - mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_uheapq)); + mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_heapq)); mp_store_global(MP_QSTR_heappush, MP_OBJ_FROM_PTR(&mod_uheapq_heappush_obj)); mp_store_global(MP_QSTR_heappop, MP_OBJ_FROM_PTR(&mod_uheapq_heappop_obj)); mp_store_global(MP_QSTR_heapify, MP_OBJ_FROM_PTR(&mod_uheapq_heapify_obj)); diff --git a/examples/natmod/urandom/urandom.c b/examples/natmod/urandom/urandom.c index e1fed6a554f..bb41bf3f8ee 100644 --- a/examples/natmod/urandom/urandom.c +++ b/examples/natmod/urandom/urandom.c @@ -16,7 +16,7 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a yasmarang_n = 69; yasmarang_d = 233; - mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_urandom)); + mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_random)); mp_store_global(MP_QSTR_getrandbits, MP_OBJ_FROM_PTR(&mod_urandom_getrandbits_obj)); mp_store_global(MP_QSTR_seed, MP_OBJ_FROM_PTR(&mod_urandom_seed_obj)); #if MICROPY_PY_URANDOM_EXTRA_FUNCS diff --git a/examples/natmod/ure/ure.c b/examples/natmod/ure/ure.c index d4bd680abd4..c51df2a4759 100644 --- a/examples/natmod/ure/ure.c +++ b/examples/natmod/ure/ure.c @@ -63,7 +63,7 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a MP_OBJ_TYPE_SET_SLOT(&match_type, locals_dict, (void*)&match_locals_dict, 1); re_type.base.type = (void*)&mp_fun_table.type_type; - re_type.name = MP_QSTR_ure; + re_type.name = MP_QSTR_re; MP_OBJ_TYPE_SET_SLOT(&re_type, print, re_print, 0); re_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_match), MP_OBJ_FROM_PTR(&re_match_obj) }; re_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_search), MP_OBJ_FROM_PTR(&re_search_obj) }; diff --git a/examples/natmod/uzlib/uzlib.c b/examples/natmod/uzlib/uzlib.c index 9cf58b10e78..06b24f4b818 100644 --- a/examples/natmod/uzlib/uzlib.c +++ b/examples/natmod/uzlib/uzlib.c @@ -27,7 +27,7 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a decompio_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_readline), MP_OBJ_FROM_PTR(&mp_stream_unbuffered_readline_obj) }; MP_OBJ_TYPE_SET_SLOT(&decompio_type, locals_dict, (void*)&decompio_locals_dict, 2); - mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_uzlib)); + mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_zlib)); mp_store_global(MP_QSTR_decompress, MP_OBJ_FROM_PTR(&mod_uzlib_decompress_obj)); mp_store_global(MP_QSTR_DecompIO, MP_OBJ_FROM_PTR(&decompio_type)); diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c index e65851d6b4b..35ba745e318 100644 --- a/extmod/modbluetooth.c +++ b/extmod/modbluetooth.c @@ -985,7 +985,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); STATIC const mp_rom_map_elem_t mp_module_bluetooth_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubluetooth) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bluetooth) }, { MP_ROM_QSTR(MP_QSTR_BLE), MP_ROM_PTR(&mp_type_bluetooth_ble) }, { MP_ROM_QSTR(MP_QSTR_UUID), MP_ROM_PTR(&mp_type_bluetooth_uuid) }, @@ -1004,7 +1004,7 @@ const mp_obj_module_t mp_module_ubluetooth = { .globals = (mp_obj_dict_t *)&mp_module_bluetooth_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ubluetooth, mp_module_ubluetooth); +MP_REGISTER_MODULE(MP_QSTR_bluetooth, mp_module_ubluetooth); // Helpers diff --git a/extmod/modlwip.c b/extmod/modlwip.c index 734722f83a1..19df1ea5030 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -1802,7 +1802,7 @@ const mp_obj_module_t mp_module_lwip = { MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip); // On LWIP-ports, this is the usocket module (replaces extmod/modusocket.c). -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_lwip); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_lwip); MP_REGISTER_ROOT_POINTER(mp_obj_t lwip_slip_stream); diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index 45a39c58d44..85205bc3d13 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -184,7 +184,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj, 1, 2, mod_bin #endif STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubinascii) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_binascii) }, #if MICROPY_PY_BUILTINS_BYTES_HEX { MP_ROM_QSTR(MP_QSTR_hexlify), MP_ROM_PTR(&bytes_hex_as_bytes_obj) }, { MP_ROM_QSTR(MP_QSTR_unhexlify), MP_ROM_PTR(&bytes_fromhex_obj) }, @@ -203,6 +203,6 @@ const mp_obj_module_t mp_module_ubinascii = { .globals = (mp_obj_dict_t *)&mp_module_binascii_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ubinascii, mp_module_ubinascii); +MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_ubinascii); #endif // MICROPY_PY_UBINASCII diff --git a/extmod/moducryptolib.c b/extmod/moducryptolib.c index fc3fcfd90d9..730ae4c6f5d 100644 --- a/extmod/moducryptolib.c +++ b/extmod/moducryptolib.c @@ -357,7 +357,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); STATIC const mp_rom_map_elem_t mp_module_ucryptolib_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ucryptolib) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cryptolib) }, { MP_ROM_QSTR(MP_QSTR_aes), MP_ROM_PTR(&ucryptolib_aes_type) }, #if MICROPY_PY_UCRYPTOLIB_CONSTS { MP_ROM_QSTR(MP_QSTR_MODE_ECB), MP_ROM_INT(UCRYPTOLIB_MODE_ECB) }, @@ -375,6 +375,6 @@ const mp_obj_module_t mp_module_ucryptolib = { .globals = (mp_obj_dict_t *)&mp_module_ucryptolib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ucryptolib, mp_module_ucryptolib); +MP_REGISTER_MODULE(MP_QSTR_cryptolib, mp_module_ucryptolib); #endif // MICROPY_PY_UCRYPTOLIB diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index 64e15c444df..addf094765a 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -355,7 +355,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( #endif // MICROPY_PY_UHASHLIB_MD5 STATIC const mp_rom_map_elem_t mp_module_uhashlib_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uhashlib) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_hashlib) }, #if MICROPY_PY_UHASHLIB_SHA256 { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&uhashlib_sha256_type) }, #endif @@ -374,6 +374,6 @@ const mp_obj_module_t mp_module_uhashlib = { .globals = (mp_obj_dict_t *)&mp_module_uhashlib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib); +MP_REGISTER_MODULE(MP_QSTR_hashlib, mp_module_uhashlib); #endif // MICROPY_PY_UHASHLIB diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c index bfa6ba608d3..9c3df65258e 100644 --- a/extmod/moduheapq.c +++ b/extmod/moduheapq.c @@ -105,7 +105,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heapify_obj, mod_uheapq_heapify); #if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_rom_map_elem_t mp_module_uheapq_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uheapq) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_heapq) }, { MP_ROM_QSTR(MP_QSTR_heappush), MP_ROM_PTR(&mod_uheapq_heappush_obj) }, { MP_ROM_QSTR(MP_QSTR_heappop), MP_ROM_PTR(&mod_uheapq_heappop_obj) }, { MP_ROM_QSTR(MP_QSTR_heapify), MP_ROM_PTR(&mod_uheapq_heapify_obj) }, @@ -118,7 +118,7 @@ const mp_obj_module_t mp_module_uheapq = { .globals = (mp_obj_dict_t *)&mp_module_uheapq_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uheapq, mp_module_uheapq); +MP_REGISTER_MODULE(MP_QSTR_heapq, mp_module_uheapq); #endif #endif // MICROPY_PY_UHEAPQ diff --git a/extmod/modujson.c b/extmod/modujson.c index 4e992e2245d..106595aab6f 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -367,7 +367,7 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_loads_obj, mod_ujson_loads); STATIC const mp_rom_map_elem_t mp_module_ujson_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ujson) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_json) }, { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_ujson_dump_obj) }, { MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_ujson_dumps_obj) }, { MP_ROM_QSTR(MP_QSTR_load), MP_ROM_PTR(&mod_ujson_load_obj) }, @@ -381,6 +381,6 @@ const mp_obj_module_t mp_module_ujson = { .globals = (mp_obj_dict_t *)&mp_module_ujson_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ujson, mp_module_ujson); +MP_REGISTER_MODULE(MP_QSTR_json, mp_module_ujson); #endif // MICROPY_PY_UJSON diff --git a/extmod/moduos.c b/extmod/moduos.c index a245ae7283a..a7d15ef966d 100644 --- a/extmod/moduos.c +++ b/extmod/moduos.c @@ -122,7 +122,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_uos_uname_obj, mp_uos_uname); #endif STATIC const mp_rom_map_elem_t os_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_os) }, #if MICROPY_PY_UOS_GETENV_PUTENV_UNSETENV { MP_ROM_QSTR(MP_QSTR_getenv), MP_ROM_PTR(&mp_uos_getenv_obj) }, @@ -141,7 +141,7 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { #if MICROPY_PY_UOS_UNAME { MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&mp_uos_uname_obj) }, #endif - #if MICROPY_PY_UOS_URANDOM + #if MICROPY_PY_OS_URANDOM { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_uos_urandom_obj) }, #endif @@ -195,6 +195,6 @@ const mp_obj_module_t mp_module_uos = { .globals = (mp_obj_dict_t *)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos); +MP_REGISTER_MODULE(MP_QSTR_os, mp_module_uos); #endif // MICROPY_PY_UOS diff --git a/extmod/moduplatform.c b/extmod/moduplatform.c index 1b35b08aa72..079e275362e 100644 --- a/extmod/moduplatform.c +++ b/extmod/moduplatform.c @@ -62,7 +62,7 @@ STATIC mp_obj_t platform_libc_ver(size_t n_args, const mp_obj_t *pos_args, mp_ma STATIC MP_DEFINE_CONST_FUN_OBJ_KW(platform_libc_ver_obj, 0, platform_libc_ver); STATIC const mp_rom_map_elem_t modplatform_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uplatform) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_platform) }, { MP_ROM_QSTR(MP_QSTR_platform), MP_ROM_PTR(&platform_platform_obj) }, { MP_ROM_QSTR(MP_QSTR_python_compiler), MP_ROM_PTR(&platform_python_compiler_obj) }, { MP_ROM_QSTR(MP_QSTR_libc_ver), MP_ROM_PTR(&platform_libc_ver_obj) }, @@ -75,6 +75,6 @@ const mp_obj_module_t mp_module_uplatform = { .globals = (mp_obj_dict_t *)&modplatform_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uplatform, mp_module_uplatform); +MP_REGISTER_MODULE(MP_QSTR_platform, mp_module_uplatform); #endif // MICROPY_PY_UPLATFORM diff --git a/extmod/modurandom.c b/extmod/modurandom.c index b6616271903..6b59c0ae397 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -231,7 +231,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_urandom___init___obj, mod_urandom___init__) #if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_rom_map_elem_t mp_module_urandom_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_urandom) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_random) }, #if SEED_ON_IMPORT { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&mod_urandom___init___obj) }, #endif @@ -255,7 +255,7 @@ const mp_obj_module_t mp_module_urandom = { .globals = (mp_obj_dict_t *)&mp_module_urandom_globals, }; -MP_REGISTER_MODULE(MP_QSTR_urandom, mp_module_urandom); +MP_REGISTER_MODULE(MP_QSTR_random, mp_module_urandom); #endif #endif // MICROPY_PY_URANDOM diff --git a/extmod/modure.c b/extmod/modure.c index 801e5df8977..c27125bf1c8 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -414,7 +414,7 @@ STATIC MP_DEFINE_CONST_DICT(re_locals_dict, re_locals_dict_table); STATIC MP_DEFINE_CONST_OBJ_TYPE( re_type, - MP_QSTR_ure, + MP_QSTR_re, MP_TYPE_FLAG_NONE, print, re_print, locals_dict, &re_locals_dict @@ -451,7 +451,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_compile_obj, 1, 2, mod_re_compile); #if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_rom_map_elem_t mp_module_re_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ure) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_re) }, { MP_ROM_QSTR(MP_QSTR_compile), MP_ROM_PTR(&mod_re_compile_obj) }, { MP_ROM_QSTR(MP_QSTR_match), MP_ROM_PTR(&re_match_obj) }, { MP_ROM_QSTR(MP_QSTR_search), MP_ROM_PTR(&re_search_obj) }, @@ -470,7 +470,7 @@ const mp_obj_module_t mp_module_ure = { .globals = (mp_obj_dict_t *)&mp_module_re_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ure, mp_module_ure); +MP_REGISTER_MODULE(MP_QSTR_re, mp_module_ure); #endif // Source files #include'd here to make sure they're compiled in diff --git a/extmod/moduselect.c b/extmod/moduselect.c index 128154a4b6d..4df0f4d561a 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -355,7 +355,7 @@ STATIC mp_obj_t select_poll(void) { MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll); STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uselect) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_select) }, #if MICROPY_PY_USELECT_SELECT { MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_select_select_obj) }, #endif @@ -373,6 +373,6 @@ const mp_obj_module_t mp_module_uselect = { .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect); +MP_REGISTER_MODULE(MP_QSTR_select, mp_module_uselect); #endif // MICROPY_PY_USELECT diff --git a/extmod/modusocket.c b/extmod/modusocket.c index 2aa6010884a..6d14ebdfb07 100644 --- a/extmod/modusocket.c +++ b/extmod/modusocket.c @@ -616,7 +616,7 @@ STATIC mp_obj_t mod_usocket_getaddrinfo(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_usocket_getaddrinfo_obj, 2, 6, mod_usocket_getaddrinfo); STATIC const mp_rom_map_elem_t mp_module_usocket_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usocket) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socket_type) }, { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&mod_usocket_getaddrinfo_obj) }, @@ -653,6 +653,6 @@ const mp_obj_module_t mp_module_usocket = { .globals = (mp_obj_dict_t *)&mp_module_usocket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket); #endif // MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP diff --git a/extmod/modussl_axtls.c b/extmod/modussl_axtls.c index 77e942ec12a..393a945facf 100644 --- a/extmod/modussl_axtls.c +++ b/extmod/modussl_axtls.c @@ -316,9 +316,9 @@ STATIC const mp_stream_p_t ussl_socket_stream_p = { STATIC MP_DEFINE_CONST_OBJ_TYPE( ussl_socket_type, - MP_QSTR_ussl, - MP_TYPE_FLAG_NONE, // Save on qstr's, reuse same as for module + MP_QSTR_ssl, + MP_TYPE_FLAG_NONE, print, ussl_socket_print, protocol, &ussl_socket_stream_p, locals_dict, &ussl_socket_locals_dict @@ -346,7 +346,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket); STATIC const mp_rom_map_elem_t mp_module_ssl_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ussl) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ssl) }, { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&mod_ssl_wrap_socket_obj) }, }; @@ -357,6 +357,6 @@ const mp_obj_module_t mp_module_ussl = { .globals = (mp_obj_dict_t *)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl); +MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ussl); #endif // MICROPY_PY_USSL && MICROPY_SSL_AXTLS diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c index 74a59fdb67b..c12c943d8a6 100644 --- a/extmod/modussl_mbedtls.c +++ b/extmod/modussl_mbedtls.c @@ -461,9 +461,9 @@ STATIC const mp_stream_p_t ussl_socket_stream_p = { STATIC MP_DEFINE_CONST_OBJ_TYPE( ussl_socket_type, - MP_QSTR_ussl, - MP_TYPE_FLAG_NONE, // Save on qstr's, reuse same as for module + MP_QSTR_ssl, + MP_TYPE_FLAG_NONE, print, socket_print, protocol, &ussl_socket_stream_p, locals_dict, &ussl_socket_locals_dict @@ -493,7 +493,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket); STATIC const mp_rom_map_elem_t mp_module_ssl_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ussl) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ssl) }, { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&mod_ssl_wrap_socket_obj) }, { MP_ROM_QSTR(MP_QSTR_CERT_NONE), MP_ROM_INT(MBEDTLS_SSL_VERIFY_NONE) }, { MP_ROM_QSTR(MP_QSTR_CERT_OPTIONAL), MP_ROM_INT(MBEDTLS_SSL_VERIFY_OPTIONAL) }, @@ -507,6 +507,6 @@ const mp_obj_module_t mp_module_ussl = { .globals = (mp_obj_dict_t *)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl); +MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ussl); #endif // MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS diff --git a/extmod/modutime.c b/extmod/modutime.c index d82ac6a27c9..5d8148f98ad 100644 --- a/extmod/modutime.c +++ b/extmod/modutime.c @@ -197,7 +197,7 @@ STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) { MP_DEFINE_CONST_FUN_OBJ_2(mp_utime_ticks_add_obj, time_ticks_add); STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utime) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) }, #if MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME { MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&mp_utime_localtime_obj) }, @@ -231,6 +231,6 @@ const mp_obj_module_t mp_module_utime = { .globals = (mp_obj_dict_t *)&mp_module_time_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime); +MP_REGISTER_MODULE(MP_QSTR_time, mp_module_utime); #endif // MICROPY_PY_UTIME diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c index 1a38104eafc..4aa572934f9 100644 --- a/extmod/modutimeq.c +++ b/extmod/modutimeq.c @@ -211,7 +211,7 @@ STATIC MP_DEFINE_CONST_DICT(utimeq_locals_dict, utimeq_locals_dict_table); STATIC MP_DEFINE_CONST_OBJ_TYPE( utimeq_type, - MP_QSTR_utimeq, + MP_QSTR_timeq, MP_TYPE_FLAG_NONE, make_new, utimeq_make_new, unary_op, utimeq_unary_op, @@ -219,8 +219,8 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); STATIC const mp_rom_map_elem_t mp_module_utimeq_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utimeq) }, - { MP_ROM_QSTR(MP_QSTR_utimeq), MP_ROM_PTR(&utimeq_type) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_timeq) }, + { MP_ROM_QSTR(MP_QSTR_timeq), MP_ROM_PTR(&utimeq_type) }, }; STATIC MP_DEFINE_CONST_DICT(mp_module_utimeq_globals, mp_module_utimeq_globals_table); @@ -230,6 +230,6 @@ const mp_obj_module_t mp_module_utimeq = { .globals = (mp_obj_dict_t *)&mp_module_utimeq_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utimeq, mp_module_utimeq); +MP_REGISTER_MODULE(MP_QSTR_timeq, mp_module_utimeq); #endif // MICROPY_PY_UTIMEQ diff --git a/extmod/moduwebsocket.c b/extmod/moduwebsocket.c index 9b12fc86358..ca7152bb13c 100644 --- a/extmod/moduwebsocket.c +++ b/extmod/moduwebsocket.c @@ -300,7 +300,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); STATIC const mp_rom_map_elem_t uwebsocket_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uwebsocket) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_websocket) }, { MP_ROM_QSTR(MP_QSTR_websocket), MP_ROM_PTR(&websocket_type) }, }; @@ -311,6 +311,6 @@ const mp_obj_module_t mp_module_uwebsocket = { .globals = (mp_obj_dict_t *)&uwebsocket_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uwebsocket, mp_module_uwebsocket); +MP_REGISTER_MODULE(MP_QSTR_websocket, mp_module_uwebsocket); #endif // MICROPY_PY_UWEBSOCKET diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index 14d15321a3c..f41ca2b0129 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -211,7 +211,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_u #if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_rom_map_elem_t mp_module_uzlib_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uzlib) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_zlib) }, { MP_ROM_QSTR(MP_QSTR_decompress), MP_ROM_PTR(&mod_uzlib_decompress_obj) }, { MP_ROM_QSTR(MP_QSTR_DecompIO), MP_ROM_PTR(&decompio_type) }, }; @@ -224,7 +224,7 @@ const mp_obj_module_t mp_module_uzlib = { }; -MP_REGISTER_MODULE(MP_QSTR_uzlib, mp_module_uzlib); +MP_REGISTER_MODULE(MP_QSTR_zlib, mp_module_uzlib); #endif // Source files #include'd here to make sure they're compiled in diff --git a/ports/cc3200/mods/modmachine.c b/ports/cc3200/mods/modmachine.c index 3e483e0a23d..c5b06f50777 100644 --- a/ports/cc3200/mods/modmachine.c +++ b/ports/cc3200/mods/modmachine.c @@ -162,7 +162,7 @@ STATIC mp_obj_t machine_wake_reason (void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_wake_reason_obj, machine_wake_reason); STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, #ifdef DEBUG @@ -214,5 +214,5 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t*)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); MP_REGISTER_ROOT_POINTER(mp_obj_t machine_config_main); diff --git a/ports/cc3200/mods/moduhashlib.c b/ports/cc3200/mods/moduhashlib.c index 302ff335ff8..5424a6c0fb4 100644 --- a/ports/cc3200/mods/moduhashlib.c +++ b/ports/cc3200/mods/moduhashlib.c @@ -194,7 +194,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); STATIC const mp_rom_map_elem_t mp_module_hashlib_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uhashlib) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_hashlib) }, //{ MP_ROM_QSTR(MP_QSTR_md5), MP_ROM_PTR(&md5_type) }, { MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&sha1_type) }, { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&sha256_type) }, diff --git a/ports/cc3200/mods/moduos.c b/ports/cc3200/mods/moduos.c index e284e9eb1ff..b3f3bbf8d8b 100644 --- a/ports/cc3200/mods/moduos.c +++ b/ports/cc3200/mods/moduos.c @@ -146,7 +146,7 @@ STATIC mp_obj_t os_dupterm(uint n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(os_dupterm_obj, 0, 1, os_dupterm); STATIC const mp_rom_map_elem_t os_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_os) }, { MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&os_uname_obj) }, @@ -180,4 +180,4 @@ const mp_obj_module_t mp_module_uos = { .globals = (mp_obj_dict_t*)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos); +MP_REGISTER_MODULE(MP_QSTR_os, mp_module_uos); diff --git a/ports/cc3200/mods/modusocket.c b/ports/cc3200/mods/modusocket.c index cd1489fb4ae..311a4395fb0 100644 --- a/ports/cc3200/mods/modusocket.c +++ b/ports/cc3200/mods/modusocket.c @@ -795,7 +795,7 @@ STATIC mp_obj_t mod_usocket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_usocket_getaddrinfo_obj, mod_usocket_getaddrinfo); STATIC const mp_rom_map_elem_t mp_module_usocket_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usocket) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socket_type) }, { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&mod_usocket_getaddrinfo_obj) }, @@ -818,4 +818,4 @@ const mp_obj_module_t mp_module_usocket = { .globals = (mp_obj_dict_t*)&mp_module_usocket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket); diff --git a/ports/cc3200/mods/modussl.c b/ports/cc3200/mods/modussl.c index 118cbd06f8f..e2de7b05cbc 100644 --- a/ports/cc3200/mods/modussl.c +++ b/ports/cc3200/mods/modussl.c @@ -62,7 +62,7 @@ STATIC const mp_obj_type_t ssl_socket_type; // locals and stream methods STATIC MP_DEFINE_CONST_OBJ_TYPE( ssl_socket_type, - MP_QSTR_ussl, + MP_QSTR_ssl, MP_TYPE_FLAG_NONE, protocol, &socket_stream_p, locals_dict, &socket_locals_dict @@ -136,7 +136,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 0, mod_ssl_wrap_socket); STATIC const mp_rom_map_elem_t mp_module_ussl_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ussl) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ssl) }, { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&mod_ssl_wrap_socket_obj) }, // class exceptions @@ -160,4 +160,4 @@ const mp_obj_module_t mp_module_ussl = { .globals = (mp_obj_dict_t*)&mp_module_ussl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl); +MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ussl); diff --git a/ports/cc3200/mpconfigport.h b/ports/cc3200/mpconfigport.h index cb71a28f34e..6bdaa9b5530 100644 --- a/ports/cc3200/mpconfigport.h +++ b/ports/cc3200/mpconfigport.h @@ -136,7 +136,7 @@ // extra constants #define MICROPY_PORT_CONSTANTS \ - { MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&mp_module_machine) }, \ + { MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&mp_module_machine) }, \ #define MP_STATE_PORT MP_STATE_VM diff --git a/ports/esp32/modmachine.c b/ports/esp32/modmachine.c index 37d4f424d42..a863f716c71 100644 --- a/ports/esp32/modmachine.c +++ b/ports/esp32/modmachine.c @@ -272,7 +272,7 @@ STATIC mp_obj_t machine_enable_irq(mp_obj_t state_in) { MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq); STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_mem8), MP_ROM_PTR(&machine_mem8_obj) }, { MP_ROM_QSTR(MP_QSTR_mem16), MP_ROM_PTR(&machine_mem16_obj) }, @@ -353,6 +353,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index 9812eb34768..5e07d1f4f5d 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -844,7 +844,7 @@ STATIC mp_obj_t esp_socket_initialize() { STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_socket_initialize_obj, esp_socket_initialize); STATIC const mp_rom_map_elem_t mp_module_socket_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usocket) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&esp_socket_initialize_obj) }, { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socket_type) }, { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&esp_socket_getaddrinfo_obj) }, @@ -872,4 +872,4 @@ const mp_obj_module_t mp_module_usocket = { // Note: This port doesn't define MICROPY_PY_USOCKET or MICROPY_PY_LWIP so // this will not conflict with the common implementation provided by // extmod/mod{lwip,usocket}.c. -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket); diff --git a/ports/esp8266/modmachine.c b/ports/esp8266/modmachine.c index 3c75a2d7ffd..383f46dda70 100644 --- a/ports/esp8266/modmachine.c +++ b/ports/esp8266/modmachine.c @@ -396,7 +396,7 @@ mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t } STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_mem8), MP_ROM_PTR(&machine_mem8_obj) }, { MP_ROM_QSTR(MP_QSTR_mem16), MP_ROM_PTR(&machine_mem16_obj) }, { MP_ROM_QSTR(MP_QSTR_mem32), MP_ROM_PTR(&machine_mem32_obj) }, @@ -456,6 +456,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/mimxrt/modmachine.c b/ports/mimxrt/modmachine.c index 7b00470cca5..098c3b949a2 100644 --- a/ports/mimxrt/modmachine.c +++ b/ports/mimxrt/modmachine.c @@ -130,7 +130,7 @@ NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_bootloader_obj, 0, 1, machine_bootloader); STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) }, { MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, @@ -185,6 +185,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/nrf/modules/machine/modmachine.c b/ports/nrf/modules/machine/modmachine.c index b080a526cf7..b7cbdc7b2da 100644 --- a/ports/nrf/modules/machine/modmachine.c +++ b/ports/nrf/modules/machine/modmachine.c @@ -205,7 +205,7 @@ STATIC mp_obj_t machine_disable_irq(void) { MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq); STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_info_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) }, @@ -266,6 +266,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t*)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/nrf/modules/uos/moduos.c b/ports/nrf/modules/uos/moduos.c index 402096aacd7..bb490127078 100644 --- a/ports/nrf/modules/uos/moduos.c +++ b/ports/nrf/modules/uos/moduos.c @@ -138,7 +138,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_os_dupterm_obj, 0, 1, os_dupterm); #endif // MICROPY_PY_MACHINE_UART STATIC const mp_rom_map_elem_t os_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_os) }, { MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&os_uname_obj) }, @@ -197,4 +197,4 @@ const mp_obj_module_t mp_module_uos = { .globals = (mp_obj_dict_t*)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos); +MP_REGISTER_MODULE(MP_QSTR_os, mp_module_uos); diff --git a/ports/qemu-arm/modmachine.c b/ports/qemu-arm/modmachine.c index 515452f41d2..1f9151ff741 100644 --- a/ports/qemu-arm/modmachine.c +++ b/ports/qemu-arm/modmachine.c @@ -31,7 +31,7 @@ #if MICROPY_PY_MACHINE STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_mem8), MP_ROM_PTR(&machine_mem8_obj) }, { MP_ROM_QSTR(MP_QSTR_mem16), MP_ROM_PTR(&machine_mem16_obj) }, @@ -48,6 +48,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/renesas-ra/README.md b/ports/renesas-ra/README.md index 896d465d2d0..1e5e2ed0cf4 100644 --- a/ports/renesas-ra/README.md +++ b/ports/renesas-ra/README.md @@ -4,8 +4,8 @@ This is a port of MicroPython to the Renesas RA family of microcontrollers. Currently supported features are: - Filesystem on the internal flash using FatFs. -- `utime` module with sleep, time, and ticks functions. -- `uos` module with VFS support. +- `time` module with sleep, time, and ticks functions. +- `os` module with VFS support. - `machine` module with the following classes: `Pin`, `ADC`, `I2C`, `SPI`, `SoftI2C`, `SoftSPI`, `UART`, `RTC` - sdcard driver if frozen driver is installed. diff --git a/ports/renesas-ra/modmachine.c b/ports/renesas-ra/modmachine.c index ecb028983c6..07e6103aaac 100644 --- a/ports/renesas-ra/modmachine.c +++ b/ports/renesas-ra/modmachine.c @@ -251,7 +251,7 @@ STATIC mp_obj_t machine_reset_cause(void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause); STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_info_obj) }, { MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, @@ -307,6 +307,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/renesas-ra/mpconfigport.h b/ports/renesas-ra/mpconfigport.h index 7dbe941c0e2..42834c1fbc7 100644 --- a/ports/renesas-ra/mpconfigport.h +++ b/ports/renesas-ra/mpconfigport.h @@ -139,7 +139,7 @@ #if MICROPY_PY_MACHINE #define MACHINE_BUILTIN_MODULE_CONSTANTS \ - { MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&mp_module_machine) }, \ + { MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&mp_module_machine) }, \ { MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&mp_module_machine) }, #else #define MACHINE_BUILTIN_MODULE_CONSTANTS diff --git a/ports/rp2/README.md b/ports/rp2/README.md index 078919ce819..3f152b8181f 100644 --- a/ports/rp2/README.md +++ b/ports/rp2/README.md @@ -6,8 +6,8 @@ Currently supported features are: - REPL over USB VCP, and optionally over UART (on GP0/GP1). - Filesystem on the internal flash, using littlefs2. - Support for native code generation and inline assembler. -- `utime` module with sleep, time and ticks functions. -- `uos` module with VFS support. +- `time` module with sleep, time and ticks functions. +- `os` module with VFS support. - `machine` module with the following classes: `Pin`, `ADC`, `PWM`, `I2C`, `SPI`, `SoftI2C`, `SoftSPI`, `Timer`, `UART`, `WDT`. - `rp2` module with programmable IO (PIO) support. diff --git a/ports/rp2/modmachine.c b/ports/rp2/modmachine.c index 81154c94cec..61b91bda0a7 100644 --- a/ports/rp2/modmachine.c +++ b/ports/rp2/modmachine.c @@ -229,7 +229,7 @@ STATIC mp_obj_t machine_enable_irq(mp_obj_t state_in) { MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq); STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) }, { MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, @@ -278,6 +278,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/samd/modmachine.c b/ports/samd/modmachine.c index 58ca895b45b..7e231b28b45 100644 --- a/ports/samd/modmachine.c +++ b/ports/samd/modmachine.c @@ -224,7 +224,7 @@ STATIC mp_obj_t machine_lightsleep(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_lightsleep_obj, 0, 1, machine_lightsleep); STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_bootloader), MP_ROM_PTR(&machine_bootloader_obj) }, @@ -297,6 +297,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/stm32/modmachine.c b/ports/stm32/modmachine.c index dee9689e3ba..e6eb73f9cb1 100644 --- a/ports/stm32/modmachine.c +++ b/ports/stm32/modmachine.c @@ -386,7 +386,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause); #if MICROPY_PY_MACHINE STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_info_obj) }, { MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, @@ -471,6 +471,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index fd5254082d5..62784dccf10 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -170,7 +170,7 @@ extern const struct _mp_obj_module_t stm_module; #if MICROPY_PY_MACHINE #define MACHINE_BUILTIN_MODULE_CONSTANTS \ - { MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&mp_module_machine) }, \ + { MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&mp_module_machine) }, \ { MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&mp_module_machine) }, #else #define MACHINE_BUILTIN_MODULE_CONSTANTS diff --git a/ports/unix/modmachine.c b/ports/unix/modmachine.c index 542ff50025f..29ac532d2b0 100644 --- a/ports/unix/modmachine.c +++ b/ports/unix/modmachine.c @@ -86,7 +86,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle); #endif STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, { MP_ROM_QSTR(MP_QSTR_mem8), MP_ROM_PTR(&machine_mem8_obj) }, { MP_ROM_QSTR(MP_QSTR_mem16), MP_ROM_PTR(&machine_mem16_obj) }, @@ -110,6 +110,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/unix/moduselect.c b/ports/unix/moduselect.c index 8f71813e70a..9b205d333fb 100644 --- a/ports/unix/moduselect.c +++ b/ports/unix/moduselect.c @@ -336,7 +336,7 @@ STATIC mp_obj_t select_poll(size_t n_args, const mp_obj_t *args) { MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_poll_obj, 0, 1, select_poll); STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uselect) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_select) }, { MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_select_poll_obj) }, { MP_ROM_QSTR(MP_QSTR_POLLIN), MP_ROM_INT(POLLIN) }, { MP_ROM_QSTR(MP_QSTR_POLLOUT), MP_ROM_INT(POLLOUT) }, @@ -351,6 +351,6 @@ const mp_obj_module_t mp_module_uselect = { .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect); +MP_REGISTER_MODULE(MP_QSTR_select, mp_module_uselect); #endif // MICROPY_PY_USELECT_POSIX diff --git a/ports/unix/modusocket.c b/ports/unix/modusocket.c index a32fc601631..2d4eeec346d 100644 --- a/ports/unix/modusocket.c +++ b/ports/unix/modusocket.c @@ -674,7 +674,7 @@ STATIC mp_obj_t mod_socket_sockaddr(mp_obj_t sockaddr_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_socket_sockaddr_obj, mod_socket_sockaddr); STATIC const mp_rom_map_elem_t mp_module_socket_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usocket) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&mp_type_socket) }, { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&mod_socket_getaddrinfo_obj) }, { MP_ROM_QSTR(MP_QSTR_inet_pton), MP_ROM_PTR(&mod_socket_inet_pton_obj) }, @@ -708,6 +708,6 @@ const mp_obj_module_t mp_module_socket = { .globals = (mp_obj_dict_t *)&mp_module_socket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_socket); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); #endif // MICROPY_PY_SOCKET diff --git a/ports/zephyr/README.md b/ports/zephyr/README.md index f9bd45344b3..3de793b2fec 100644 --- a/ports/zephyr/README.md +++ b/ports/zephyr/README.md @@ -12,11 +12,11 @@ should work with MicroPython (but not all were tested). Features supported at this time: * REPL (interactive prompt) over Zephyr UART console. -* `utime` module for time measurements and delays. +* `time` module for time measurements and delays. * `machine.Pin` class for GPIO control, with IRQ support. * `machine.I2C` class for I2C control. * `machine.SPI` class for SPI control. -* `usocket` module for networking (IPv4/IPv6). +* `socket` module for networking (IPv4/IPv6). * "Frozen modules" support to allow to bundle Python modules together with firmware. Including complete applications, including with run-on-boot capability. diff --git a/ports/zephyr/modmachine.c b/ports/zephyr/modmachine.c index 95a66c51199..6f4bbbdab61 100644 --- a/ports/zephyr/modmachine.c +++ b/ports/zephyr/modmachine.c @@ -61,7 +61,7 @@ STATIC mp_obj_t machine_idle(void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle); STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) }, #ifdef CONFIG_REBOOT { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, #endif @@ -89,6 +89,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine); +MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/zephyr/modusocket.c b/ports/zephyr/modusocket.c index c79f73a9d27..98dff7e8e80 100644 --- a/ports/zephyr/modusocket.c +++ b/ports/zephyr/modusocket.c @@ -449,7 +449,7 @@ STATIC mp_obj_t pkt_get_info(void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(pkt_get_info_obj, pkt_get_info); STATIC const mp_rom_map_elem_t mp_module_usocket_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usocket) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, // objects { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socket_type) }, // class constants @@ -473,6 +473,6 @@ const mp_obj_module_t mp_module_usocket = { .globals = (mp_obj_dict_t *)&mp_module_usocket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket); #endif // MICROPY_PY_USOCKET diff --git a/py/modarray.c b/py/modarray.c index d9f7a045288..c91e92f798b 100644 --- a/py/modarray.c +++ b/py/modarray.c @@ -29,7 +29,7 @@ #if MICROPY_PY_ARRAY STATIC const mp_rom_map_elem_t mp_module_array_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uarray) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_array) }, { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_type_array) }, }; @@ -40,6 +40,6 @@ const mp_obj_module_t mp_module_uarray = { .globals = (mp_obj_dict_t *)&mp_module_array_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uarray, mp_module_uarray); +MP_REGISTER_MODULE(MP_QSTR_array, mp_module_uarray); #endif diff --git a/py/modcollections.c b/py/modcollections.c index 8c62f34db7e..a56fe069eaa 100644 --- a/py/modcollections.c +++ b/py/modcollections.c @@ -29,7 +29,7 @@ #if MICROPY_PY_COLLECTIONS STATIC const mp_rom_map_elem_t mp_module_collections_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ucollections) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_collections) }, #if MICROPY_PY_COLLECTIONS_DEQUE { MP_ROM_QSTR(MP_QSTR_deque), MP_ROM_PTR(&mp_type_deque) }, #endif @@ -46,6 +46,6 @@ const mp_obj_module_t mp_module_collections = { .globals = (mp_obj_dict_t *)&mp_module_collections_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ucollections, mp_module_collections); +MP_REGISTER_MODULE(MP_QSTR_collections, mp_module_collections); #endif // MICROPY_PY_COLLECTIONS diff --git a/py/modio.c b/py/modio.c index 9ec6bbcc4ec..3462611d719 100644 --- a/py/modio.c +++ b/py/modio.c @@ -203,7 +203,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( #endif // MICROPY_PY_IO_BUFFEREDWRITER STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uio) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io) }, // Note: mp_builtin_open_obj should be defined by port, it's not // part of the core. { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, @@ -226,6 +226,6 @@ const mp_obj_module_t mp_module_io = { .globals = (mp_obj_dict_t *)&mp_module_io_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uio, mp_module_io); +MP_REGISTER_MODULE(MP_QSTR_io, mp_module_io); #endif diff --git a/py/modstruct.c b/py/modstruct.c index ec86d4b9c29..78c7d53e4bb 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -251,7 +251,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into); STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ustruct) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_struct) }, { MP_ROM_QSTR(MP_QSTR_calcsize), MP_ROM_PTR(&struct_calcsize_obj) }, { MP_ROM_QSTR(MP_QSTR_pack), MP_ROM_PTR(&struct_pack_obj) }, { MP_ROM_QSTR(MP_QSTR_pack_into), MP_ROM_PTR(&struct_pack_into_obj) }, @@ -266,6 +266,6 @@ const mp_obj_module_t mp_module_ustruct = { .globals = (mp_obj_dict_t *)&mp_module_struct_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ustruct, mp_module_ustruct); +MP_REGISTER_MODULE(MP_QSTR_struct, mp_module_ustruct); #endif diff --git a/py/modsys.c b/py/modsys.c index 35af761a08f..09bdfefc634 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -294,7 +294,7 @@ const mp_obj_module_t mp_module_sys = { .globals = (mp_obj_dict_t *)&mp_module_sys_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usys, mp_module_sys); +MP_REGISTER_MODULE(MP_QSTR_sys, mp_module_sys); // If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is not enabled then these two lists // must be initialised after the call to mp_init. diff --git a/py/moduerrno.c b/py/moduerrno.c index 1b16fd9d9ed..e197f921e15 100644 --- a/py/moduerrno.c +++ b/py/moduerrno.c @@ -82,7 +82,7 @@ STATIC const mp_obj_dict_t errorcode_dict = { #endif STATIC const mp_rom_map_elem_t mp_module_uerrno_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uerrno) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_errno) }, #if MICROPY_PY_UERRNO_ERRORCODE { MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) }, #endif @@ -99,7 +99,7 @@ const mp_obj_module_t mp_module_uerrno = { .globals = (mp_obj_dict_t *)&mp_module_uerrno_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uerrno, mp_module_uerrno); +MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_uerrno); qstr mp_errno_to_str(mp_obj_t errno_val) { #if MICROPY_PY_UERRNO_ERRORCODE From dfe232d0003b9f381643050c06c547fc3093e9e1 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Wed, 17 Aug 2022 16:21:03 +1000 Subject: [PATCH 0009/4300] py/builtinimport: Remove weak links. In order to keep "import umodule" working, the existing mechanism is replaced with a simple fallback to drop the "u". This makes importing of built-ins no longer touch the filesystem, which makes a typical built-in import take ~0.15ms rather than 3-5ms. (Weak links were added in c14a81662c1df812c0c6b4299f97966302f16477) This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- docs/develop/porting.rst | 3 --- ports/cc3200/mpconfigport.h | 1 - ports/nrf/mpconfigport.h | 1 - ports/samd/mpconfigport.h | 1 - ports/windows/mpconfigport.h | 1 - ports/zephyr/mpconfigport.h | 1 - py/builtinimport.c | 50 ++++-------------------------------- py/mpconfig.h | 5 ---- py/objmodule.c | 1 - 9 files changed, 5 insertions(+), 59 deletions(-) diff --git a/docs/develop/porting.rst b/docs/develop/porting.rst index fab8a751b84..63919b97a6c 100644 --- a/docs/develop/porting.rst +++ b/docs/develop/porting.rst @@ -151,9 +151,6 @@ The following is an example of an ``mpconfigport.h`` file: #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) - // Enable u-modules to be imported with their standard name, like sys. - #define MICROPY_MODULE_WEAK_LINKS (1) - // Fine control over Python builtins, classes, modules, etc. #define MICROPY_PY_ASYNC_AWAIT (0) #define MICROPY_PY_BUILTINS_SET (0) diff --git a/ports/cc3200/mpconfigport.h b/ports/cc3200/mpconfigport.h index 6bdaa9b5530..aa78005d68b 100644 --- a/ports/cc3200/mpconfigport.h +++ b/ports/cc3200/mpconfigport.h @@ -71,7 +71,6 @@ #define MICROPY_FATFS_SYNC_T SemaphoreHandle_t #define MICROPY_STREAMS_NON_BLOCK (1) -#define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_CAN_OVERRIDE_BUILTINS (1) #define MICROPY_USE_INTERNAL_ERRNO (1) #define MICROPY_VFS (1) diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 23f7e560dc5..3d482f4fe1f 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -137,7 +137,6 @@ #define MICROPY_PY_UOS (0) #define MICROPY_STREAMS_NON_BLOCK (1) -#define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_CAN_OVERRIDE_BUILTINS (1) #define MICROPY_USE_INTERNAL_ERRNO (1) #if MICROPY_HW_USB_CDC_1200BPS_TOUCH diff --git a/ports/samd/mpconfigport.h b/ports/samd/mpconfigport.h index 7392b030590..a0a58a2fd72 100644 --- a/ports/samd/mpconfigport.h +++ b/ports/samd/mpconfigport.h @@ -59,7 +59,6 @@ #define MICROPY_PY_BUILTINS_HELP_MODULES (1) #define MICROPY_ENABLE_SCHEDULER (1) #define MICROPY_SCHEDULER_STATIC_NODES (1) -#define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_HW_ENABLE_USBDEV (1) #define MICROPY_HW_USB_CDC_1200BPS_TOUCH (1) diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h index fd3a76408cd..5e56923d93b 100644 --- a/ports/windows/mpconfigport.h +++ b/ports/windows/mpconfigport.h @@ -72,7 +72,6 @@ #endif #define MICROPY_STREAMS_POSIX_API (1) #define MICROPY_OPT_COMPUTED_GOTO (0) -#define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (1) #define MICROPY_CAN_OVERRIDE_BUILTINS (1) #ifndef MICROPY_ENABLE_SCHEDULER diff --git a/ports/zephyr/mpconfigport.h b/ports/zephyr/mpconfigport.h index d3ef4375c7f..30ccccb6272 100644 --- a/ports/zephyr/mpconfigport.h +++ b/ports/zephyr/mpconfigport.h @@ -69,7 +69,6 @@ #define MICROPY_PY_MACHINE_SPI_MSB (SPI_TRANSFER_MSB) #define MICROPY_PY_MACHINE_SPI_LSB (SPI_TRANSFER_LSB) #define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new -#define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_PY_STRUCT (0) #ifdef CONFIG_NETWORKING // If we have networking, we likely want errno comfort diff --git a/py/builtinimport.c b/py/builtinimport.c index 8827be61233..299877de639 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -45,15 +45,6 @@ #define DEBUG_printf(...) (void)0 #endif -#if MICROPY_MODULE_WEAK_LINKS -STATIC qstr make_weak_link_name(vstr_t *buffer, qstr name) { - vstr_reset(buffer); - vstr_add_char(buffer, 'u'); - vstr_add_str(buffer, qstr_str(name)); - return qstr_from_strn(buffer->buf, buffer->len); -} -#endif - #if MICROPY_ENABLE_EXTERNAL_IMPORT // Must be a string of one byte. @@ -391,13 +382,8 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, if (outer_module_obj == MP_OBJ_NULL) { DEBUG_printf("Searching for top-level module\n"); - // An exact match of a built-in will always bypass the filesystem. - // Note that CPython-compatible built-ins are named e.g. utime, so this - // means that an exact match is only for `import utime`, so `import - // time` will search the filesystem and failing that hit the weak - // link handling below. Whereas micropython-specific built-ins like - // `micropython`, `pyb`, `network`, etc will match exactly and cannot - // be overridden by the filesystem. + // An import of a non-extensible built-in will always bypass the + // filesystem. e.g. `import micropython` or `import pyb`. module_obj = mp_module_get_builtin(level_mod_name); if (module_obj != MP_OBJ_NULL) { return module_obj; @@ -417,20 +403,9 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, // relative to all the locations in sys.path. stat = stat_top_level(level_mod_name, &path); - #if MICROPY_MODULE_WEAK_LINKS - if (stat == MP_IMPORT_STAT_NO_EXIST) { - // No match on the filesystem. (And not a built-in either). - // If "foo" was requested, then try "ufoo" as a built-in. This - // allows `import time` to use built-in `utime`, unless `time` - // exists on the filesystem. This feature was formerly known - // as "weak links". - qstr umodule_name = make_weak_link_name(&path, level_mod_name); - module_obj = mp_module_get_builtin(umodule_name); - if (module_obj != MP_OBJ_NULL) { - return module_obj; - } - } - #endif + // TODO: If stat failed, now try extensible built-in modules. + + // TODO: If importing `ufoo`, try `foo`. } else { DEBUG_printf("Searching for sub-module\n"); @@ -667,21 +642,6 @@ mp_obj_t mp_builtin___import___default(size_t n_args, const mp_obj_t *args) { return module_obj; } - #if MICROPY_MODULE_WEAK_LINKS - // Check if the u-prefixed name is a built-in. - VSTR_FIXED(umodule_path, MICROPY_ALLOC_PATH_MAX); - qstr umodule_name_qstr = make_weak_link_name(&umodule_path, module_name_qstr); - module_obj = mp_module_get_builtin(umodule_name_qstr); - if (module_obj != MP_OBJ_NULL) { - return module_obj; - } - #elif MICROPY_PY_SYS - // Special handling to make `import sys` work even if weak links aren't enabled. - if (module_name_qstr == MP_QSTR_sys) { - return MP_OBJ_FROM_PTR(&mp_module_sys); - } - #endif - // Couldn't find the module, so fail #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE mp_raise_msg(&mp_type_ImportError, MP_ERROR_TEXT("module not found")); diff --git a/py/mpconfig.h b/py/mpconfig.h index afef744ab5b..9f4d88ec09d 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -871,11 +871,6 @@ typedef double mp_float_t; #define MICROPY_MODULE_GETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif -// Whether module weak links are supported -#ifndef MICROPY_MODULE_WEAK_LINKS -#define MICROPY_MODULE_WEAK_LINKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) -#endif - // Whether to enable importing foo.py with __name__ set to '__main__' // Used by the unix port for the -m flag. #ifndef MICROPY_MODULE_OVERRIDE_MAIN_IMPORT diff --git a/py/objmodule.c b/py/objmodule.c index 7326fbe2d12..e63fb18a1ea 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -169,7 +169,6 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { // builtin modules declared with MP_REGISTER_MODULE() MICROPY_REGISTERED_MODULES }; - MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table); // Attempts to find (and initialise) a builtin, otherwise returns From 1bf2dcb15ecf4ba37211327f4378b164a5aaf567 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 18 Aug 2022 14:47:56 +1000 Subject: [PATCH 0010/4300] all: Rename mp_umodule*, mp_module_umodule* to remove the "u" prefix. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- extmod/misc.h | 16 ++--- extmod/modbluetooth.c | 4 +- extmod/modubinascii.c | 4 +- extmod/moducryptolib.c | 10 +-- extmod/moduhashlib.c | 10 +-- extmod/moduheapq.c | 10 +-- extmod/modujson.c | 10 +-- extmod/moduos.c | 66 ++++++++++---------- extmod/moduplatform.c | 4 +- extmod/modurandom.c | 10 +-- extmod/modure.c | 4 +- extmod/moduselect.c | 4 +- extmod/modusocket.c | 10 +-- extmod/modussl_axtls.c | 4 +- extmod/modussl_mbedtls.c | 4 +- extmod/modutime.c | 60 +++++++++--------- extmod/modutime.h | 20 +++--- extmod/modutimeq.c | 10 +-- extmod/moduwebsocket.c | 4 +- extmod/moduzlib.c | 10 +-- extmod/uos_dupterm.c | 26 ++++---- extmod/utime_mphal.c | 0 ports/cc3200/mods/moduhashlib.c | 2 +- ports/cc3200/mods/moduos.c | 4 +- ports/cc3200/mods/modusocket.c | 10 +-- ports/cc3200/mods/modussl.c | 10 +-- ports/cc3200/mods/modutime.c | 4 +- ports/esp32/modsocket.c | 4 +- ports/esp32/moduos.c | 10 +-- ports/esp32/modutime.c | 4 +- ports/esp32/mphalport.c | 2 +- ports/esp8266/esp_mphal.c | 6 +- ports/esp8266/main.c | 2 +- ports/esp8266/moduos.c | 12 ++-- ports/esp8266/modutime.c | 4 +- ports/mimxrt/moduos.c | 10 +-- ports/mimxrt/modutime.c | 4 +- ports/mimxrt/mphalport.c | 6 +- ports/nrf/modules/uos/moduos.c | 4 +- ports/renesas-ra/moduos.c | 4 +- ports/renesas-ra/modutime.c | 4 +- ports/renesas-ra/mphalport.c | 6 +- ports/rp2/moduos.c | 4 +- ports/rp2/modutime.c | 4 +- ports/rp2/mphalport.c | 6 +- ports/samd/moduos.c | 12 ++-- ports/samd/modutime.c | 4 +- ports/samd/mphalport.c | 6 +- ports/stm32/modpyb.c | 10 +-- ports/stm32/moduos.c | 8 +-- ports/stm32/modutime.c | 4 +- ports/stm32/mphalport.c | 6 +- ports/stm32/portmodules.h | 4 +- ports/unix/main.c | 2 +- ports/unix/moduos.c | 24 +++---- ports/unix/moduselect.c | 4 +- ports/unix/modutime.c | 4 +- ports/unix/mpconfigport.h | 2 +- ports/unix/unix_mphal.c | 2 +- ports/unix/variants/mpconfigvariant_common.h | 2 +- ports/zephyr/modusocket.c | 10 +-- ports/zephyr/modutime.c | 2 +- py/builtin.h | 2 +- py/modarray.c | 4 +- py/modstruct.c | 4 +- py/moduerrno.c | 16 ++--- py/parse.c | 2 +- 67 files changed, 280 insertions(+), 280 deletions(-) create mode 100644 extmod/utime_mphal.c diff --git a/extmod/misc.h b/extmod/misc.h index a9392aa10b7..80e5b59a08e 100644 --- a/extmod/misc.h +++ b/extmod/misc.h @@ -32,17 +32,17 @@ #include #include "py/runtime.h" -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_dupterm_obj); +MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_dupterm_obj); #if MICROPY_PY_OS_DUPTERM -bool mp_uos_dupterm_is_builtin_stream(mp_const_obj_t stream); -void mp_uos_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached); -uintptr_t mp_uos_dupterm_poll(uintptr_t poll_flags); -int mp_uos_dupterm_rx_chr(void); -void mp_uos_dupterm_tx_strn(const char *str, size_t len); -void mp_uos_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc); +bool mp_os_dupterm_is_builtin_stream(mp_const_obj_t stream); +void mp_os_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached); +uintptr_t mp_os_dupterm_poll(uintptr_t poll_flags); +int mp_os_dupterm_rx_chr(void); +void mp_os_dupterm_tx_strn(const char *str, size_t len); +void mp_os_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc); #else -#define mp_uos_dupterm_tx_strn(s, l) +#define mp_os_dupterm_tx_strn(s, l) #endif #endif // MICROPY_INCLUDED_EXTMOD_MISC_H diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c index 35ba745e318..628c643a586 100644 --- a/extmod/modbluetooth.c +++ b/extmod/modbluetooth.c @@ -999,12 +999,12 @@ STATIC const mp_rom_map_elem_t mp_module_bluetooth_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_bluetooth_globals, mp_module_bluetooth_globals_table); -const mp_obj_module_t mp_module_ubluetooth = { +const mp_obj_module_t mp_module_bluetooth = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_bluetooth_globals, }; -MP_REGISTER_MODULE(MP_QSTR_bluetooth, mp_module_ubluetooth); +MP_REGISTER_MODULE(MP_QSTR_bluetooth, mp_module_bluetooth); // Helpers diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index 85205bc3d13..bfb8195d919 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -198,11 +198,11 @@ STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table); -const mp_obj_module_t mp_module_ubinascii = { +const mp_obj_module_t mp_module_binascii = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_binascii_globals, }; -MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_ubinascii); +MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_binascii); #endif // MICROPY_PY_UBINASCII diff --git a/extmod/moducryptolib.c b/extmod/moducryptolib.c index 730ae4c6f5d..e727f50548a 100644 --- a/extmod/moducryptolib.c +++ b/extmod/moducryptolib.c @@ -356,7 +356,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( locals_dict, &ucryptolib_aes_locals_dict ); -STATIC const mp_rom_map_elem_t mp_module_ucryptolib_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_cryptolib_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cryptolib) }, { MP_ROM_QSTR(MP_QSTR_aes), MP_ROM_PTR(&ucryptolib_aes_type) }, #if MICROPY_PY_UCRYPTOLIB_CONSTS @@ -368,13 +368,13 @@ STATIC const mp_rom_map_elem_t mp_module_ucryptolib_globals_table[] = { #endif }; -STATIC MP_DEFINE_CONST_DICT(mp_module_ucryptolib_globals, mp_module_ucryptolib_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_cryptolib_globals, mp_module_cryptolib_globals_table); -const mp_obj_module_t mp_module_ucryptolib = { +const mp_obj_module_t mp_module_cryptolib = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_ucryptolib_globals, + .globals = (mp_obj_dict_t *)&mp_module_cryptolib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_cryptolib, mp_module_ucryptolib); +MP_REGISTER_MODULE(MP_QSTR_cryptolib, mp_module_cryptolib); #endif // MICROPY_PY_UCRYPTOLIB diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index addf094765a..ef1a29fc789 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -354,7 +354,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); #endif // MICROPY_PY_UHASHLIB_MD5 -STATIC const mp_rom_map_elem_t mp_module_uhashlib_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_hashlib_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_hashlib) }, #if MICROPY_PY_UHASHLIB_SHA256 { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&uhashlib_sha256_type) }, @@ -367,13 +367,13 @@ STATIC const mp_rom_map_elem_t mp_module_uhashlib_globals_table[] = { #endif }; -STATIC MP_DEFINE_CONST_DICT(mp_module_uhashlib_globals, mp_module_uhashlib_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_hashlib_globals, mp_module_hashlib_globals_table); -const mp_obj_module_t mp_module_uhashlib = { +const mp_obj_module_t mp_module_hashlib = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_uhashlib_globals, + .globals = (mp_obj_dict_t *)&mp_module_hashlib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_hashlib, mp_module_uhashlib); +MP_REGISTER_MODULE(MP_QSTR_hashlib, mp_module_hashlib); #endif // MICROPY_PY_UHASHLIB diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c index 9c3df65258e..fb6cb81182e 100644 --- a/extmod/moduheapq.c +++ b/extmod/moduheapq.c @@ -104,21 +104,21 @@ STATIC mp_obj_t mod_uheapq_heapify(mp_obj_t heap_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heapify_obj, mod_uheapq_heapify); #if !MICROPY_ENABLE_DYNRUNTIME -STATIC const mp_rom_map_elem_t mp_module_uheapq_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_heapq_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_heapq) }, { MP_ROM_QSTR(MP_QSTR_heappush), MP_ROM_PTR(&mod_uheapq_heappush_obj) }, { MP_ROM_QSTR(MP_QSTR_heappop), MP_ROM_PTR(&mod_uheapq_heappop_obj) }, { MP_ROM_QSTR(MP_QSTR_heapify), MP_ROM_PTR(&mod_uheapq_heapify_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(mp_module_uheapq_globals, mp_module_uheapq_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_heapq_globals, mp_module_heapq_globals_table); -const mp_obj_module_t mp_module_uheapq = { +const mp_obj_module_t mp_module_heapq = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_uheapq_globals, + .globals = (mp_obj_dict_t *)&mp_module_heapq_globals, }; -MP_REGISTER_MODULE(MP_QSTR_heapq, mp_module_uheapq); +MP_REGISTER_MODULE(MP_QSTR_heapq, mp_module_heapq); #endif #endif // MICROPY_PY_UHEAPQ diff --git a/extmod/modujson.c b/extmod/modujson.c index 106595aab6f..44dd316b699 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -366,7 +366,7 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_loads_obj, mod_ujson_loads); -STATIC const mp_rom_map_elem_t mp_module_ujson_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_json_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_json) }, { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_ujson_dump_obj) }, { MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_ujson_dumps_obj) }, @@ -374,13 +374,13 @@ STATIC const mp_rom_map_elem_t mp_module_ujson_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_loads), MP_ROM_PTR(&mod_ujson_loads_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(mp_module_ujson_globals, mp_module_ujson_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_json_globals, mp_module_json_globals_table); -const mp_obj_module_t mp_module_ujson = { +const mp_obj_module_t mp_module_json = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_ujson_globals, + .globals = (mp_obj_dict_t *)&mp_module_json_globals, }; -MP_REGISTER_MODULE(MP_QSTR_json, mp_module_ujson); +MP_REGISTER_MODULE(MP_QSTR_json, mp_module_json); #endif // MICROPY_PY_UJSON diff --git a/extmod/moduos.c b/extmod/moduos.c index a7d15ef966d..8c40f453703 100644 --- a/extmod/moduos.c +++ b/extmod/moduos.c @@ -65,7 +65,7 @@ #if MICROPY_PY_UOS_SYNC // sync() // Sync all filesystems. -STATIC mp_obj_t mp_uos_sync(void) { +STATIC mp_obj_t mp_os_sync(void) { #if MICROPY_VFS_FAT for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { // this assumes that vfs->obj is fs_user_mount_t with block device functions @@ -74,7 +74,7 @@ STATIC mp_obj_t mp_uos_sync(void) { #endif return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_0(mp_uos_sync_obj, mp_uos_sync); +MP_DEFINE_CONST_FUN_OBJ_0(mp_os_sync_obj, mp_os_sync); #endif #if MICROPY_PY_UOS_UNAME @@ -85,39 +85,39 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_uos_sync_obj, mp_uos_sync); #define CONST_RELEASE const #endif -STATIC const qstr mp_uos_uname_info_fields[] = { +STATIC const qstr mp_os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -STATIC const MP_DEFINE_STR_OBJ(mp_uos_uname_info_sysname_obj, MICROPY_PY_SYS_PLATFORM); -STATIC const MP_DEFINE_STR_OBJ(mp_uos_uname_info_nodename_obj, MICROPY_PY_SYS_PLATFORM); -STATIC CONST_RELEASE MP_DEFINE_STR_OBJ(mp_uos_uname_info_release_obj, MICROPY_VERSION_STRING); -STATIC const MP_DEFINE_STR_OBJ(mp_uos_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE MICROPY_BUILD_TYPE_PAREN); -STATIC const MP_DEFINE_STR_OBJ(mp_uos_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); +STATIC const MP_DEFINE_STR_OBJ(mp_os_uname_info_sysname_obj, MICROPY_PY_SYS_PLATFORM); +STATIC const MP_DEFINE_STR_OBJ(mp_os_uname_info_nodename_obj, MICROPY_PY_SYS_PLATFORM); +STATIC CONST_RELEASE MP_DEFINE_STR_OBJ(mp_os_uname_info_release_obj, MICROPY_VERSION_STRING); +STATIC const MP_DEFINE_STR_OBJ(mp_os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE MICROPY_BUILD_TYPE_PAREN); +STATIC const MP_DEFINE_STR_OBJ(mp_os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); STATIC MP_DEFINE_ATTRTUPLE( - mp_uos_uname_info_obj, - mp_uos_uname_info_fields, + mp_os_uname_info_obj, + mp_os_uname_info_fields, 5, - MP_ROM_PTR(&mp_uos_uname_info_sysname_obj), - MP_ROM_PTR(&mp_uos_uname_info_nodename_obj), - MP_ROM_PTR(&mp_uos_uname_info_release_obj), - MP_ROM_PTR(&mp_uos_uname_info_version_obj), - MP_ROM_PTR(&mp_uos_uname_info_machine_obj) + MP_ROM_PTR(&mp_os_uname_info_sysname_obj), + MP_ROM_PTR(&mp_os_uname_info_nodename_obj), + MP_ROM_PTR(&mp_os_uname_info_release_obj), + MP_ROM_PTR(&mp_os_uname_info_version_obj), + MP_ROM_PTR(&mp_os_uname_info_machine_obj) ); -STATIC mp_obj_t mp_uos_uname(void) { +STATIC mp_obj_t mp_os_uname(void) { #if MICROPY_PY_UOS_UNAME_RELEASE_DYNAMIC - const char *release = mp_uos_uname_release(); - mp_uos_uname_info_release_obj.len = strlen(release); - mp_uos_uname_info_release_obj.data = (const byte *)release; + const char *release = mp_os_uname_release(); + mp_os_uname_info_release_obj.len = strlen(release); + mp_os_uname_info_release_obj.data = (const byte *)release; #endif - return MP_OBJ_FROM_PTR(&mp_uos_uname_info_obj); + return MP_OBJ_FROM_PTR(&mp_os_uname_info_obj); } -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_uos_uname_obj, mp_uos_uname); +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_os_uname_obj, mp_os_uname); #endif @@ -125,24 +125,24 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_os) }, #if MICROPY_PY_UOS_GETENV_PUTENV_UNSETENV - { MP_ROM_QSTR(MP_QSTR_getenv), MP_ROM_PTR(&mp_uos_getenv_obj) }, - { MP_ROM_QSTR(MP_QSTR_putenv), MP_ROM_PTR(&mp_uos_putenv_obj) }, - { MP_ROM_QSTR(MP_QSTR_unsetenv), MP_ROM_PTR(&mp_uos_unsetenv_obj) }, + { MP_ROM_QSTR(MP_QSTR_getenv), MP_ROM_PTR(&mp_os_getenv_obj) }, + { MP_ROM_QSTR(MP_QSTR_putenv), MP_ROM_PTR(&mp_os_putenv_obj) }, + { MP_ROM_QSTR(MP_QSTR_unsetenv), MP_ROM_PTR(&mp_os_unsetenv_obj) }, #endif #if MICROPY_PY_UOS_SEP { MP_ROM_QSTR(MP_QSTR_sep), MP_ROM_QSTR(MP_QSTR__slash_) }, #endif #if MICROPY_PY_UOS_SYNC - { MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&mp_uos_sync_obj) }, + { MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&mp_os_sync_obj) }, #endif #if MICROPY_PY_UOS_SYSTEM - { MP_ROM_QSTR(MP_QSTR_system), MP_ROM_PTR(&mp_uos_system_obj) }, + { MP_ROM_QSTR(MP_QSTR_system), MP_ROM_PTR(&mp_os_system_obj) }, #endif #if MICROPY_PY_UOS_UNAME - { MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&mp_uos_uname_obj) }, + { MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&mp_os_uname_obj) }, #endif #if MICROPY_PY_OS_URANDOM - { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_uos_urandom_obj) }, + { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_os_urandom_obj) }, #endif #if MICROPY_VFS @@ -161,13 +161,13 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { // The following are MicroPython extensions. #if MICROPY_PY_OS_DUPTERM - { MP_ROM_QSTR(MP_QSTR_dupterm), MP_ROM_PTR(&mp_uos_dupterm_obj) }, + { MP_ROM_QSTR(MP_QSTR_dupterm), MP_ROM_PTR(&mp_os_dupterm_obj) }, #endif #if MICROPY_PY_UOS_DUPTERM_NOTIFY - { MP_ROM_QSTR(MP_QSTR_dupterm_notify), MP_ROM_PTR(&mp_uos_dupterm_notify_obj) }, + { MP_ROM_QSTR(MP_QSTR_dupterm_notify), MP_ROM_PTR(&mp_os_dupterm_notify_obj) }, #endif #if MICROPY_PY_UOS_ERRNO - { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_uos_errno_obj) }, + { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_os_errno_obj) }, #endif #if MICROPY_VFS @@ -190,11 +190,11 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { }; STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table); -const mp_obj_module_t mp_module_uos = { +const mp_obj_module_t mp_module_os = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_os, mp_module_uos); +MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os); #endif // MICROPY_PY_UOS diff --git a/extmod/moduplatform.c b/extmod/moduplatform.c index 079e275362e..791ae8344d9 100644 --- a/extmod/moduplatform.c +++ b/extmod/moduplatform.c @@ -70,11 +70,11 @@ STATIC const mp_rom_map_elem_t modplatform_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(modplatform_globals, modplatform_globals_table); -const mp_obj_module_t mp_module_uplatform = { +const mp_obj_module_t mp_module_platform = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&modplatform_globals, }; -MP_REGISTER_MODULE(MP_QSTR_platform, mp_module_uplatform); +MP_REGISTER_MODULE(MP_QSTR_platform, mp_module_platform); #endif // MICROPY_PY_UPLATFORM diff --git a/extmod/modurandom.c b/extmod/modurandom.c index 6b59c0ae397..86e3a872c55 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -230,7 +230,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_urandom___init___obj, mod_urandom___init__) #endif #if !MICROPY_ENABLE_DYNRUNTIME -STATIC const mp_rom_map_elem_t mp_module_urandom_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_random_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_random) }, #if SEED_ON_IMPORT { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&mod_urandom___init___obj) }, @@ -248,14 +248,14 @@ STATIC const mp_rom_map_elem_t mp_module_urandom_globals_table[] = { #endif }; -STATIC MP_DEFINE_CONST_DICT(mp_module_urandom_globals, mp_module_urandom_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_random_globals, mp_module_random_globals_table); -const mp_obj_module_t mp_module_urandom = { +const mp_obj_module_t mp_module_random = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_urandom_globals, + .globals = (mp_obj_dict_t *)&mp_module_random_globals, }; -MP_REGISTER_MODULE(MP_QSTR_random, mp_module_urandom); +MP_REGISTER_MODULE(MP_QSTR_random, mp_module_random); #endif #endif // MICROPY_PY_URANDOM diff --git a/extmod/modure.c b/extmod/modure.c index c27125bf1c8..4798f07b0be 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -465,12 +465,12 @@ STATIC const mp_rom_map_elem_t mp_module_re_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_re_globals, mp_module_re_globals_table); -const mp_obj_module_t mp_module_ure = { +const mp_obj_module_t mp_module_re = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_re_globals, }; -MP_REGISTER_MODULE(MP_QSTR_re, mp_module_ure); +MP_REGISTER_MODULE(MP_QSTR_re, mp_module_re); #endif // Source files #include'd here to make sure they're compiled in diff --git a/extmod/moduselect.c b/extmod/moduselect.c index 4df0f4d561a..5bb5f4f48df 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -368,11 +368,11 @@ STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_table); -const mp_obj_module_t mp_module_uselect = { +const mp_obj_module_t mp_module_select = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; -MP_REGISTER_MODULE(MP_QSTR_select, mp_module_uselect); +MP_REGISTER_MODULE(MP_QSTR_select, mp_module_select); #endif // MICROPY_PY_USELECT diff --git a/extmod/modusocket.c b/extmod/modusocket.c index 6d14ebdfb07..6c2b4ff06fd 100644 --- a/extmod/modusocket.c +++ b/extmod/modusocket.c @@ -615,7 +615,7 @@ STATIC mp_obj_t mod_usocket_getaddrinfo(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_usocket_getaddrinfo_obj, 2, 6, mod_usocket_getaddrinfo); -STATIC const mp_rom_map_elem_t mp_module_usocket_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_socket_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socket_type) }, @@ -646,13 +646,13 @@ STATIC const mp_rom_map_elem_t mp_module_usocket_globals_table[] = { */ }; -STATIC MP_DEFINE_CONST_DICT(mp_module_usocket_globals, mp_module_usocket_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_socket_globals, mp_module_socket_globals_table); -const mp_obj_module_t mp_module_usocket = { +const mp_obj_module_t mp_module_socket = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_usocket_globals, + .globals = (mp_obj_dict_t *)&mp_module_socket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); #endif // MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP diff --git a/extmod/modussl_axtls.c b/extmod/modussl_axtls.c index 393a945facf..6e490a594a0 100644 --- a/extmod/modussl_axtls.c +++ b/extmod/modussl_axtls.c @@ -352,11 +352,11 @@ STATIC const mp_rom_map_elem_t mp_module_ssl_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_ssl_globals, mp_module_ssl_globals_table); -const mp_obj_module_t mp_module_ussl = { +const mp_obj_module_t mp_module_ssl = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ussl); +MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl); #endif // MICROPY_PY_USSL && MICROPY_SSL_AXTLS diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c index c12c943d8a6..117a06b6b28 100644 --- a/extmod/modussl_mbedtls.c +++ b/extmod/modussl_mbedtls.c @@ -502,11 +502,11 @@ STATIC const mp_rom_map_elem_t mp_module_ssl_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_ssl_globals, mp_module_ssl_globals_table); -const mp_obj_module_t mp_module_ussl = { +const mp_obj_module_t mp_module_ssl = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ussl); +MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl); #endif // MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS diff --git a/extmod/modutime.c b/extmod/modutime.c index 5d8148f98ad..9731f5ff0b2 100644 --- a/extmod/modutime.c +++ b/extmod/modutime.c @@ -55,7 +55,7 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) { if (n_args == 0 || args[0] == mp_const_none) { // Get current date and time. - return mp_utime_localtime_get(); + return mp_time_localtime_get(); } else { // Convert given seconds to tuple. mp_int_t seconds = mp_obj_get_int(args[0]); @@ -74,7 +74,7 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) { return mp_obj_new_tuple(8, tuple); } } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_utime_localtime_obj, 0, 1, time_localtime); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_time_localtime_obj, 0, 1, time_localtime); // mktime() // This is the inverse function of localtime. Its argument is a full 8-tuple @@ -94,7 +94,7 @@ STATIC mp_obj_t time_mktime(mp_obj_t tuple) { mp_obj_get_int(elem[1]), mp_obj_get_int(elem[2]), mp_obj_get_int(elem[3]), mp_obj_get_int(elem[4]), mp_obj_get_int(elem[5]))); } -MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_mktime_obj, time_mktime); +MP_DEFINE_CONST_FUN_OBJ_1(mp_time_mktime_obj, time_mktime); #endif // MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME @@ -103,22 +103,22 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_mktime_obj, time_mktime); // time() // Return the number of seconds since the Epoch. STATIC mp_obj_t time_time(void) { - return mp_utime_time_get(); + return mp_time_time_get(); } -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_time_obj, time_time); +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_obj, time_time); // time_ns() // Returns the number of nanoseconds since the Epoch, as an integer. STATIC mp_obj_t time_time_ns(void) { return mp_obj_new_int_from_ull(mp_hal_time_ns()); } -MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_time_ns_obj, time_time_ns); +MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_ns_obj, time_time_ns); #endif // MICROPY_PY_UTIME_TIME_TIME_NS STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { #ifdef MICROPY_PY_UTIME_CUSTOM_SLEEP - mp_utime_sleep(seconds_o); + mp_time_sleep(seconds_o); #else #if MICROPY_PY_BUILTINS_FLOAT mp_hal_delay_ms((mp_uint_t)(1000 * mp_obj_get_float(seconds_o))); @@ -128,7 +128,7 @@ STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { #endif return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep); +MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_obj, time_sleep); STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) { mp_int_t ms = mp_obj_get_int(arg); @@ -137,7 +137,7 @@ STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) { } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj, time_sleep_ms); +MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_ms_obj, time_sleep_ms); STATIC mp_obj_t time_sleep_us(mp_obj_t arg) { mp_int_t us = mp_obj_get_int(arg); @@ -146,22 +146,22 @@ STATIC mp_obj_t time_sleep_us(mp_obj_t arg) { } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_us_obj, time_sleep_us); +MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_us_obj, time_sleep_us); STATIC mp_obj_t time_ticks_ms(void) { return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); } -MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_ms_obj, time_ticks_ms); +MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_ms_obj, time_ticks_ms); STATIC mp_obj_t time_ticks_us(void) { return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_us() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); } -MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_us_obj, time_ticks_us); +MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_us_obj, time_ticks_us); STATIC mp_obj_t time_ticks_cpu(void) { return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_cpu() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); } -MP_DEFINE_CONST_FUN_OBJ_0(mp_utime_ticks_cpu_obj, time_ticks_cpu); +MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_cpu_obj, time_ticks_cpu); STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) { // we assume that the arguments come from ticks_xx so are small ints @@ -173,7 +173,7 @@ STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) { - MICROPY_PY_UTIME_TICKS_PERIOD / 2; return MP_OBJ_NEW_SMALL_INT(diff); } -MP_DEFINE_CONST_FUN_OBJ_2(mp_utime_ticks_diff_obj, time_ticks_diff); +MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_diff_obj, time_ticks_diff); STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) { // we assume that first argument come from ticks_xx so is small int @@ -194,31 +194,31 @@ STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) { return MP_OBJ_NEW_SMALL_INT((ticks + delta) & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); } -MP_DEFINE_CONST_FUN_OBJ_2(mp_utime_ticks_add_obj, time_ticks_add); +MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_add_obj, time_ticks_add); STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) }, #if MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME - { MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&mp_utime_localtime_obj) }, - { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&mp_utime_localtime_obj) }, - { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&mp_utime_mktime_obj) }, + { MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&mp_time_localtime_obj) }, + { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&mp_time_localtime_obj) }, + { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&mp_time_mktime_obj) }, #endif #if MICROPY_PY_UTIME_TIME_TIME_NS - { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mp_utime_time_obj) }, - { MP_ROM_QSTR(MP_QSTR_time_ns), MP_ROM_PTR(&mp_utime_time_ns_obj) }, + { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mp_time_time_obj) }, + { MP_ROM_QSTR(MP_QSTR_time_ns), MP_ROM_PTR(&mp_time_time_ns_obj) }, #endif - { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mp_utime_sleep_obj) }, - { MP_ROM_QSTR(MP_QSTR_sleep_ms), MP_ROM_PTR(&mp_utime_sleep_ms_obj) }, - { MP_ROM_QSTR(MP_QSTR_sleep_us), MP_ROM_PTR(&mp_utime_sleep_us_obj) }, + { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mp_time_sleep_obj) }, + { MP_ROM_QSTR(MP_QSTR_sleep_ms), MP_ROM_PTR(&mp_time_sleep_ms_obj) }, + { MP_ROM_QSTR(MP_QSTR_sleep_us), MP_ROM_PTR(&mp_time_sleep_us_obj) }, - { MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&mp_utime_ticks_ms_obj) }, - { MP_ROM_QSTR(MP_QSTR_ticks_us), MP_ROM_PTR(&mp_utime_ticks_us_obj) }, - { MP_ROM_QSTR(MP_QSTR_ticks_cpu), MP_ROM_PTR(&mp_utime_ticks_cpu_obj) }, - { MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_utime_ticks_add_obj) }, - { MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_utime_ticks_diff_obj) }, + { MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&mp_time_ticks_ms_obj) }, + { MP_ROM_QSTR(MP_QSTR_ticks_us), MP_ROM_PTR(&mp_time_ticks_us_obj) }, + { MP_ROM_QSTR(MP_QSTR_ticks_cpu), MP_ROM_PTR(&mp_time_ticks_cpu_obj) }, + { MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_time_ticks_add_obj) }, + { MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_time_ticks_diff_obj) }, #ifdef MICROPY_PY_UTIME_EXTRA_GLOBALS MICROPY_PY_UTIME_EXTRA_GLOBALS @@ -226,11 +226,11 @@ STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = { }; STATIC MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table); -const mp_obj_module_t mp_module_utime = { +const mp_obj_module_t mp_module_time = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_time_globals, }; -MP_REGISTER_MODULE(MP_QSTR_time, mp_module_utime); +MP_REGISTER_MODULE(MP_QSTR_time, mp_module_time); #endif // MICROPY_PY_UTIME diff --git a/extmod/modutime.h b/extmod/modutime.h index 2e10afb89bb..f5ea6b55bf3 100644 --- a/extmod/modutime.h +++ b/extmod/modutime.h @@ -29,15 +29,15 @@ #include "py/obj.h" -MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_mktime_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_us_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_ms_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_us_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_cpu_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_utime_ticks_diff_obj); -MP_DECLARE_CONST_FUN_OBJ_2(mp_utime_ticks_add_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_time_ns_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_time_mktime_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_time_sleep_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_time_sleep_ms_obj); +MP_DECLARE_CONST_FUN_OBJ_1(mp_time_sleep_us_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_time_ticks_ms_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_time_ticks_us_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_time_ticks_cpu_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_time_ticks_diff_obj); +MP_DECLARE_CONST_FUN_OBJ_2(mp_time_ticks_add_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_time_time_ns_obj); #endif // MICROPY_INCLUDED_EXTMOD_MODUTIME_H diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c index 4aa572934f9..8187fa2b23c 100644 --- a/extmod/modutimeq.c +++ b/extmod/modutimeq.c @@ -218,18 +218,18 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( locals_dict, &utimeq_locals_dict ); -STATIC const mp_rom_map_elem_t mp_module_utimeq_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_timeq_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_timeq) }, { MP_ROM_QSTR(MP_QSTR_timeq), MP_ROM_PTR(&utimeq_type) }, }; -STATIC MP_DEFINE_CONST_DICT(mp_module_utimeq_globals, mp_module_utimeq_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_timeq_globals, mp_module_timeq_globals_table); -const mp_obj_module_t mp_module_utimeq = { +const mp_obj_module_t mp_module_timeq = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_utimeq_globals, + .globals = (mp_obj_dict_t *)&mp_module_timeq_globals, }; -MP_REGISTER_MODULE(MP_QSTR_timeq, mp_module_utimeq); +MP_REGISTER_MODULE(MP_QSTR_timeq, mp_module_timeq); #endif // MICROPY_PY_UTIMEQ diff --git a/extmod/moduwebsocket.c b/extmod/moduwebsocket.c index ca7152bb13c..301f72fba04 100644 --- a/extmod/moduwebsocket.c +++ b/extmod/moduwebsocket.c @@ -306,11 +306,11 @@ STATIC const mp_rom_map_elem_t uwebsocket_module_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(uwebsocket_module_globals, uwebsocket_module_globals_table); -const mp_obj_module_t mp_module_uwebsocket = { +const mp_obj_module_t mp_module_websocket = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&uwebsocket_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_websocket, mp_module_uwebsocket); +MP_REGISTER_MODULE(MP_QSTR_websocket, mp_module_websocket); #endif // MICROPY_PY_UWEBSOCKET diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index f41ca2b0129..504c637c3c7 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -210,21 +210,21 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress); #if !MICROPY_ENABLE_DYNRUNTIME -STATIC const mp_rom_map_elem_t mp_module_uzlib_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_zlib_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_zlib) }, { MP_ROM_QSTR(MP_QSTR_decompress), MP_ROM_PTR(&mod_uzlib_decompress_obj) }, { MP_ROM_QSTR(MP_QSTR_DecompIO), MP_ROM_PTR(&decompio_type) }, }; -STATIC MP_DEFINE_CONST_DICT(mp_module_uzlib_globals, mp_module_uzlib_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_zlib_globals, mp_module_zlib_globals_table); -const mp_obj_module_t mp_module_uzlib = { +const mp_obj_module_t mp_module_zlib = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_uzlib_globals, + .globals = (mp_obj_dict_t *)&mp_module_zlib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_zlib, mp_module_uzlib); +MP_REGISTER_MODULE(MP_QSTR_zlib, mp_module_zlib); #endif // Source files #include'd here to make sure they're compiled in diff --git a/extmod/uos_dupterm.c b/extmod/uos_dupterm.c index 981d05a6383..c72b365bea0 100644 --- a/extmod/uos_dupterm.c +++ b/extmod/uos_dupterm.c @@ -38,7 +38,7 @@ #include "shared/runtime/interrupt_char.h" -void mp_uos_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc) { +void mp_os_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc) { mp_obj_t term = MP_STATE_VM(dupterm_objs[dupterm_idx]); MP_STATE_VM(dupterm_objs[dupterm_idx]) = MP_OBJ_NULL; mp_printf(&mp_plat_print, msg); @@ -54,7 +54,7 @@ void mp_uos_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc) { } } -uintptr_t mp_uos_dupterm_poll(uintptr_t poll_flags) { +uintptr_t mp_os_dupterm_poll(uintptr_t poll_flags) { uintptr_t poll_flags_out = 0; for (size_t idx = 0; idx < MICROPY_PY_OS_DUPTERM; ++idx) { @@ -67,7 +67,7 @@ uintptr_t mp_uos_dupterm_poll(uintptr_t poll_flags) { mp_uint_t ret = 0; const mp_stream_p_t *stream_p = mp_get_stream(s); #if MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM - if (mp_uos_dupterm_is_builtin_stream(s)) { + if (mp_os_dupterm_is_builtin_stream(s)) { ret = stream_p->ioctl(s, MP_STREAM_POLL, poll_flags, &errcode); } else #endif @@ -93,14 +93,14 @@ uintptr_t mp_uos_dupterm_poll(uintptr_t poll_flags) { return poll_flags_out; } -int mp_uos_dupterm_rx_chr(void) { +int mp_os_dupterm_rx_chr(void) { for (size_t idx = 0; idx < MICROPY_PY_OS_DUPTERM; ++idx) { if (MP_STATE_VM(dupterm_objs[idx]) == MP_OBJ_NULL) { continue; } #if MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM - if (mp_uos_dupterm_is_builtin_stream(MP_STATE_VM(dupterm_objs[idx]))) { + if (mp_os_dupterm_is_builtin_stream(MP_STATE_VM(dupterm_objs[idx]))) { byte buf[1]; int errcode = 0; const mp_stream_p_t *stream_p = mp_get_stream(MP_STATE_VM(dupterm_objs[idx])); @@ -121,7 +121,7 @@ int mp_uos_dupterm_rx_chr(void) { mp_uint_t out_sz = stream_p->read(MP_STATE_VM(dupterm_objs[idx]), buf, 1, &errcode); if (out_sz == 0) { nlr_pop(); - mp_uos_deactivate(idx, "dupterm: EOF received, deactivating\n", MP_OBJ_NULL); + mp_os_deactivate(idx, "dupterm: EOF received, deactivating\n", MP_OBJ_NULL); } else if (out_sz == MP_STREAM_ERROR) { // errcode is valid if (mp_is_nonblocking_error(errcode)) { @@ -140,7 +140,7 @@ int mp_uos_dupterm_rx_chr(void) { return buf[0]; } } else { - mp_uos_deactivate(idx, "dupterm: Exception in read() method, deactivating: ", MP_OBJ_FROM_PTR(nlr.ret_val)); + mp_os_deactivate(idx, "dupterm: Exception in read() method, deactivating: ", MP_OBJ_FROM_PTR(nlr.ret_val)); } } @@ -148,14 +148,14 @@ int mp_uos_dupterm_rx_chr(void) { return -1; } -void mp_uos_dupterm_tx_strn(const char *str, size_t len) { +void mp_os_dupterm_tx_strn(const char *str, size_t len) { for (size_t idx = 0; idx < MICROPY_PY_OS_DUPTERM; ++idx) { if (MP_STATE_VM(dupterm_objs[idx]) == MP_OBJ_NULL) { continue; } #if MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM - if (mp_uos_dupterm_is_builtin_stream(MP_STATE_VM(dupterm_objs[idx]))) { + if (mp_os_dupterm_is_builtin_stream(MP_STATE_VM(dupterm_objs[idx]))) { int errcode = 0; const mp_stream_p_t *stream_p = mp_get_stream(MP_STATE_VM(dupterm_objs[idx])); stream_p->write(MP_STATE_VM(dupterm_objs[idx]), str, len, &errcode); @@ -168,12 +168,12 @@ void mp_uos_dupterm_tx_strn(const char *str, size_t len) { mp_stream_write(MP_STATE_VM(dupterm_objs[idx]), str, len, MP_STREAM_RW_WRITE); nlr_pop(); } else { - mp_uos_deactivate(idx, "dupterm: Exception in write() method, deactivating: ", MP_OBJ_FROM_PTR(nlr.ret_val)); + mp_os_deactivate(idx, "dupterm: Exception in write() method, deactivating: ", MP_OBJ_FROM_PTR(nlr.ret_val)); } } } -STATIC mp_obj_t mp_uos_dupterm(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t mp_os_dupterm(size_t n_args, const mp_obj_t *args) { mp_int_t idx = 0; if (n_args == 2) { idx = mp_obj_get_int(args[1]); @@ -195,12 +195,12 @@ STATIC mp_obj_t mp_uos_dupterm(size_t n_args, const mp_obj_t *args) { } #if MICROPY_PY_UOS_DUPTERM_STREAM_DETACHED_ATTACHED - mp_uos_dupterm_stream_detached_attached(previous_obj, args[0]); + mp_os_dupterm_stream_detached_attached(previous_obj, args[0]); #endif return previous_obj; } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_dupterm_obj, 1, 2, mp_uos_dupterm); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_dupterm_obj, 1, 2, mp_os_dupterm); MP_REGISTER_ROOT_POINTER(mp_obj_t dupterm_objs[MICROPY_PY_OS_DUPTERM]); diff --git a/extmod/utime_mphal.c b/extmod/utime_mphal.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ports/cc3200/mods/moduhashlib.c b/ports/cc3200/mods/moduhashlib.c index 5424a6c0fb4..de56e114af7 100644 --- a/ports/cc3200/mods/moduhashlib.c +++ b/ports/cc3200/mods/moduhashlib.c @@ -202,7 +202,7 @@ STATIC const mp_rom_map_elem_t mp_module_hashlib_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_hashlib_globals, mp_module_hashlib_globals_table); -const mp_obj_module_t mp_module_uhashlib = { +const mp_obj_module_t mp_module_hashlib = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&mp_module_hashlib_globals, }; diff --git a/ports/cc3200/mods/moduos.c b/ports/cc3200/mods/moduos.c index b3f3bbf8d8b..a6e4ef50a7a 100644 --- a/ports/cc3200/mods/moduos.c +++ b/ports/cc3200/mods/moduos.c @@ -175,9 +175,9 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table); -const mp_obj_module_t mp_module_uos = { +const mp_obj_module_t mp_module_os = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_os, mp_module_uos); +MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os); diff --git a/ports/cc3200/mods/modusocket.c b/ports/cc3200/mods/modusocket.c index 311a4395fb0..53682743a9c 100644 --- a/ports/cc3200/mods/modusocket.c +++ b/ports/cc3200/mods/modusocket.c @@ -794,7 +794,7 @@ STATIC mp_obj_t mod_usocket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_usocket_getaddrinfo_obj, mod_usocket_getaddrinfo); -STATIC const mp_rom_map_elem_t mp_module_usocket_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_socket_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socket_type) }, @@ -811,11 +811,11 @@ STATIC const mp_rom_map_elem_t mp_module_usocket_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IPPROTO_UDP), MP_ROM_INT(SL_IPPROTO_UDP) }, }; -STATIC MP_DEFINE_CONST_DICT(mp_module_usocket_globals, mp_module_usocket_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_socket_globals, mp_module_socket_globals_table); -const mp_obj_module_t mp_module_usocket = { +const mp_obj_module_t mp_module_socket = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_usocket_globals, + .globals = (mp_obj_dict_t*)&mp_module_socket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); diff --git a/ports/cc3200/mods/modussl.c b/ports/cc3200/mods/modussl.c index e2de7b05cbc..dda6725e668 100644 --- a/ports/cc3200/mods/modussl.c +++ b/ports/cc3200/mods/modussl.c @@ -135,7 +135,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_ } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 0, mod_ssl_wrap_socket); -STATIC const mp_rom_map_elem_t mp_module_ussl_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_ssl_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ssl) }, { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&mod_ssl_wrap_socket_obj) }, @@ -153,11 +153,11 @@ STATIC const mp_rom_map_elem_t mp_module_ussl_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_PROTOCOL_TLSv1_2), MP_ROM_INT(SL_SO_SEC_METHOD_TLSV1_2) }, }; -STATIC MP_DEFINE_CONST_DICT(mp_module_ussl_globals, mp_module_ussl_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_ssl_globals, mp_module_ssl_globals_table); -const mp_obj_module_t mp_module_ussl = { +const mp_obj_module_t mp_module_ssl = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_ussl_globals, + .globals = (mp_obj_dict_t*)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ussl); +MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl); diff --git a/ports/cc3200/mods/modutime.c b/ports/cc3200/mods/modutime.c index 52eb1a60294..6fa98296d2f 100644 --- a/ports/cc3200/mods/modutime.c +++ b/ports/cc3200/mods/modutime.c @@ -30,7 +30,7 @@ #include "pybrtc.h" // Return the localtime as an 8-tuple. -STATIC mp_obj_t mp_utime_localtime_get(void) { +STATIC mp_obj_t mp_time_localtime_get(void) { timeutils_struct_time_t tm; // get the seconds from the RTC @@ -49,6 +49,6 @@ STATIC mp_obj_t mp_utime_localtime_get(void) { } // Returns the number of seconds, as an integer, since the Epoch. -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { return mp_obj_new_int(pyb_rtc_get_seconds()); } diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index 5e07d1f4f5d..81993044575 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -864,7 +864,7 @@ STATIC const mp_rom_map_elem_t mp_module_socket_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_socket_globals, mp_module_socket_globals_table); -const mp_obj_module_t mp_module_usocket = { +const mp_obj_module_t mp_module_socket = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_socket_globals, }; @@ -872,4 +872,4 @@ const mp_obj_module_t mp_module_usocket = { // Note: This port doesn't define MICROPY_PY_USOCKET or MICROPY_PY_LWIP so // this will not conflict with the common implementation provided by // extmod/mod{lwip,usocket}.c. -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); diff --git a/ports/esp32/moduos.c b/ports/esp32/moduos.c index bdfd19c5d20..6a5a26c256b 100644 --- a/ports/esp32/moduos.c +++ b/ports/esp32/moduos.c @@ -33,7 +33,7 @@ #include "py/mphal.h" #include "extmod/misc.h" -STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { +STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; vstr_init_len(&vstr, n); @@ -47,13 +47,13 @@ STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { } return mp_obj_new_bytes_from_vstr(&vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_urandom_obj, mp_uos_urandom); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); #if MICROPY_PY_UOS_DUPTERM_NOTIFY -STATIC mp_obj_t mp_uos_dupterm_notify(mp_obj_t obj_in) { +STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) { (void)obj_in; for (;;) { - int c = mp_uos_dupterm_rx_chr(); + int c = mp_os_dupterm_rx_chr(); if (c < 0) { break; } @@ -61,5 +61,5 @@ STATIC mp_obj_t mp_uos_dupterm_notify(mp_obj_t obj_in) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_dupterm_notify_obj, mp_uos_dupterm_notify); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_dupterm_notify_obj, mp_os_dupterm_notify); #endif diff --git a/ports/esp32/modutime.c b/ports/esp32/modutime.c index 7b833a194d0..7a2b2150869 100644 --- a/ports/esp32/modutime.c +++ b/ports/esp32/modutime.c @@ -32,7 +32,7 @@ #include "shared/timeutils/timeutils.h" // Return the localtime as an 8-tuple. -STATIC mp_obj_t mp_utime_localtime_get(void) { +STATIC mp_obj_t mp_time_localtime_get(void) { struct timeval tv; gettimeofday(&tv, NULL); timeutils_struct_time_t tm; @@ -51,7 +51,7 @@ STATIC mp_obj_t mp_utime_localtime_get(void) { } // Return the number of seconds since the Epoch. -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { struct timeval tv; gettimeofday(&tv, NULL); return mp_obj_new_int(tv.tv_sec); diff --git a/ports/esp32/mphalport.c b/ports/esp32/mphalport.c index b187b422d50..61e9fd563ef 100644 --- a/ports/esp32/mphalport.c +++ b/ports/esp32/mphalport.c @@ -121,7 +121,7 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) { if (release_gil) { MP_THREAD_GIL_ENTER(); } - mp_uos_dupterm_tx_strn(str, len); + mp_os_dupterm_tx_strn(str, len); } uint32_t mp_hal_ticks_ms(void) { diff --git a/ports/esp8266/esp_mphal.c b/ports/esp8266/esp_mphal.c index 219e6148412..7606bd4f631 100644 --- a/ports/esp8266/esp_mphal.c +++ b/ports/esp8266/esp_mphal.c @@ -63,7 +63,7 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { ret |= MP_STREAM_POLL_RD; } if (poll_flags & MP_STREAM_POLL_WR) { - ret |= mp_uos_dupterm_poll(poll_flags); + ret |= mp_os_dupterm_poll(poll_flags); } return ret; } @@ -95,7 +95,7 @@ void mp_hal_debug_str(const char *str) { #endif void mp_hal_stdout_tx_strn(const char *str, uint32_t len) { - mp_uos_dupterm_tx_strn(str, len); + mp_os_dupterm_tx_strn(str, len); } void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len) { @@ -146,7 +146,7 @@ STATIC void dupterm_task_handler(os_event_t *evt) { } lock = 1; while (1) { - int c = mp_uos_dupterm_rx_chr(); + int c = mp_os_dupterm_rx_chr(); if (c < 0) { break; } diff --git a/ports/esp8266/main.c b/ports/esp8266/main.c index 2aa81aba05d..3083fe364e7 100644 --- a/ports/esp8266/main.c +++ b/ports/esp8266/main.c @@ -74,7 +74,7 @@ STATIC void mp_reset(void) { args[1] = MP_OBJ_NEW_SMALL_INT(115200); args[0] = MP_OBJ_TYPE_GET_SLOT(&pyb_uart_type, make_new)(&pyb_uart_type, 2, 0, args); args[1] = MP_OBJ_NEW_SMALL_INT(1); - mp_uos_dupterm_obj.fun.var(2, args); + mp_os_dupterm_obj.fun.var(2, args); } #if MICROPY_ESPNOW diff --git a/ports/esp8266/moduos.c b/ports/esp8266/moduos.c index a023796fd3b..78072d4f448 100644 --- a/ports/esp8266/moduos.c +++ b/ports/esp8266/moduos.c @@ -37,11 +37,11 @@ #include "esp_mphal.h" #include "user_interface.h" -STATIC const char *mp_uos_uname_release(void) { +STATIC const char *mp_os_uname_release(void) { return system_get_sdk_version(); } -STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { +STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; vstr_init_len(&vstr, n); @@ -50,9 +50,9 @@ STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { } return mp_obj_new_bytes_from_vstr(&vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_urandom_obj, mp_uos_urandom); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); -void mp_uos_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached) { +void mp_os_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached) { if (mp_obj_get_type(stream_attached) == &pyb_uart_type) { ++uart_attached_to_dupterm; } @@ -61,9 +61,9 @@ void mp_uos_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t } } -STATIC mp_obj_t mp_uos_dupterm_notify(mp_obj_t obj_in) { +STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) { (void)obj_in; mp_hal_signal_dupterm_input(); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_dupterm_notify_obj, mp_uos_dupterm_notify); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_dupterm_notify_obj, mp_os_dupterm_notify); diff --git a/ports/esp8266/modutime.c b/ports/esp8266/modutime.c index b90763371b0..21dd3cbcd90 100644 --- a/ports/esp8266/modutime.c +++ b/ports/esp8266/modutime.c @@ -30,7 +30,7 @@ #include "modmachine.h" // Return the localtime as an 8-tuple. -STATIC mp_obj_t mp_utime_localtime_get(void) { +STATIC mp_obj_t mp_time_localtime_get(void) { mp_int_t seconds = pyb_rtc_get_us_since_epoch() / 1000 / 1000; timeutils_struct_time_t tm; timeutils_seconds_since_epoch_to_struct_time(seconds, &tm); @@ -48,7 +48,7 @@ STATIC mp_obj_t mp_utime_localtime_get(void) { } // Returns the number of seconds, as an integer, since the Epoch. -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { // get date and time return mp_obj_new_int(pyb_rtc_get_us_since_epoch() / 1000 / 1000); } diff --git a/ports/mimxrt/moduos.c b/ports/mimxrt/moduos.c index b3f97693fa5..8ae8019aaef 100644 --- a/ports/mimxrt/moduos.c +++ b/ports/mimxrt/moduos.c @@ -96,7 +96,7 @@ uint32_t trng_random_u32(void) { } #if MICROPY_PY_UOS_URANDOM -STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { +STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; vstr_init_len(&vstr, n); @@ -106,14 +106,14 @@ STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { return mp_obj_new_bytes_from_vstr(&vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_urandom_obj, mp_uos_urandom); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); #endif #if MICROPY_PY_UOS_DUPTERM_NOTIFY -STATIC mp_obj_t mp_uos_dupterm_notify(mp_obj_t obj_in) { +STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) { (void)obj_in; for (;;) { - int c = mp_uos_dupterm_rx_chr(); + int c = mp_os_dupterm_rx_chr(); if (c < 0) { break; } @@ -121,5 +121,5 @@ STATIC mp_obj_t mp_uos_dupterm_notify(mp_obj_t obj_in) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_dupterm_notify_obj, mp_uos_dupterm_notify); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_dupterm_notify_obj, mp_os_dupterm_notify); #endif diff --git a/ports/mimxrt/modutime.c b/ports/mimxrt/modutime.c index 5872e9d8d60..b0c927899f9 100644 --- a/ports/mimxrt/modutime.c +++ b/ports/mimxrt/modutime.c @@ -30,7 +30,7 @@ #include "fsl_snvs_lp.h" // Return the localtime as an 8-tuple. -STATIC mp_obj_t mp_utime_localtime_get(void) { +STATIC mp_obj_t mp_time_localtime_get(void) { // Get current date and time. snvs_lp_srtc_datetime_t t; SNVS_LP_SRTC_GetDatetime(SNVS, &t); @@ -48,7 +48,7 @@ STATIC mp_obj_t mp_utime_localtime_get(void) { } // Return the number of seconds since the Epoch. -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { snvs_lp_srtc_datetime_t t; SNVS_LP_SRTC_GetDatetime(SNVS, &t); // EPOCH is 1970 for this port, which leads to the following trouble: diff --git a/ports/mimxrt/mphalport.c b/ports/mimxrt/mphalport.c index beb471ab801..2114baaae4f 100644 --- a/ports/mimxrt/mphalport.c +++ b/ports/mimxrt/mphalport.c @@ -90,7 +90,7 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { ret |= MP_STREAM_POLL_WR; } #if MICROPY_PY_OS_DUPTERM - ret |= mp_uos_dupterm_poll(poll_flags); + ret |= mp_os_dupterm_poll(poll_flags); #endif return ret; } @@ -103,7 +103,7 @@ int mp_hal_stdin_rx_chr(void) { return c; } #if MICROPY_PY_OS_DUPTERM - int dupterm_c = mp_uos_dupterm_rx_chr(); + int dupterm_c = mp_os_dupterm_rx_chr(); if (dupterm_c >= 0) { return dupterm_c; } @@ -134,7 +134,7 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { } } #if MICROPY_PY_OS_DUPTERM - mp_uos_dupterm_tx_strn(str, len); + mp_os_dupterm_tx_strn(str, len); #endif } diff --git a/ports/nrf/modules/uos/moduos.c b/ports/nrf/modules/uos/moduos.c index bb490127078..b7181506134 100644 --- a/ports/nrf/modules/uos/moduos.c +++ b/ports/nrf/modules/uos/moduos.c @@ -192,9 +192,9 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table); -const mp_obj_module_t mp_module_uos = { +const mp_obj_module_t mp_module_os = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_os, mp_module_uos); +MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os); diff --git a/ports/renesas-ra/moduos.c b/ports/renesas-ra/moduos.c index 6f524f119fc..e6aadd9ebc1 100644 --- a/ports/renesas-ra/moduos.c +++ b/ports/renesas-ra/moduos.c @@ -28,12 +28,12 @@ #include "py/runtime.h" #include "uart.h" -bool mp_uos_dupterm_is_builtin_stream(mp_const_obj_t stream) { +bool mp_os_dupterm_is_builtin_stream(mp_const_obj_t stream) { const mp_obj_type_t *type = mp_obj_get_type(stream); return type == &machine_uart_type; } -void mp_uos_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached) { +void mp_os_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached) { if (mp_obj_get_type(stream_detached) == &machine_uart_type) { uart_attach_to_repl(MP_OBJ_TO_PTR(stream_detached), false); } diff --git a/ports/renesas-ra/modutime.c b/ports/renesas-ra/modutime.c index 49dcfd589dd..1ab51e336de 100644 --- a/ports/renesas-ra/modutime.c +++ b/ports/renesas-ra/modutime.c @@ -29,7 +29,7 @@ #include "rtc.h" // Return the localtime as an 8-tuple. -STATIC mp_obj_t mp_utime_localtime_get(void) { +STATIC mp_obj_t mp_time_localtime_get(void) { // get current date and time rtc_init_finalise(); ra_rtc_t time; @@ -48,7 +48,7 @@ STATIC mp_obj_t mp_utime_localtime_get(void) { } // Returns the number of seconds, as an integer, since the Epoch. -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { // get date and time rtc_init_finalise(); ra_rtc_t time; diff --git a/ports/renesas-ra/mphalport.c b/ports/renesas-ra/mphalport.c index 6e6a83aa264..b35ab757144 100644 --- a/ports/renesas-ra/mphalport.c +++ b/ports/renesas-ra/mphalport.c @@ -54,7 +54,7 @@ MP_WEAK uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { const mp_stream_p_t *stream_p = mp_get_stream(pyb_stdio_uart); ret = stream_p->ioctl(pyb_stdio_uart, MP_STREAM_POLL, poll_flags, &errcode); } - return ret | mp_uos_dupterm_poll(poll_flags); + return ret | mp_os_dupterm_poll(poll_flags); } #if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE @@ -69,7 +69,7 @@ MP_WEAK int mp_hal_stdin_rx_chr(void) { if (MP_STATE_PORT(pyb_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(pyb_stdio_uart))) { return uart_rx_char(MP_STATE_PORT(pyb_stdio_uart)); } - int dupterm_c = mp_uos_dupterm_rx_chr(); + int dupterm_c = mp_os_dupterm_rx_chr(); if (dupterm_c >= 0) { return dupterm_c; } @@ -81,7 +81,7 @@ MP_WEAK void mp_hal_stdout_tx_strn(const char *str, size_t len) { if (MP_STATE_PORT(pyb_stdio_uart) != NULL) { uart_tx_strn(MP_STATE_PORT(pyb_stdio_uart), str, len); } - mp_uos_dupterm_tx_strn(str, len); + mp_os_dupterm_tx_strn(str, len); } void mp_hal_ticks_cpu_enable(void) { diff --git a/ports/rp2/moduos.c b/ports/rp2/moduos.c index 398ec28d921..77f980a731b 100644 --- a/ports/rp2/moduos.c +++ b/ports/rp2/moduos.c @@ -28,7 +28,7 @@ uint8_t rosc_random_u8(size_t cycles); -STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { +STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; vstr_init_len(&vstr, n); @@ -37,4 +37,4 @@ STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { } return mp_obj_new_bytes_from_vstr(&vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_urandom_obj, mp_uos_urandom); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); diff --git a/ports/rp2/modutime.c b/ports/rp2/modutime.c index 9859295d1a5..b4120be7c3e 100644 --- a/ports/rp2/modutime.c +++ b/ports/rp2/modutime.c @@ -29,7 +29,7 @@ #include "hardware/rtc.h" // Return the localtime as an 8-tuple. -STATIC mp_obj_t mp_utime_localtime_get(void) { +STATIC mp_obj_t mp_time_localtime_get(void) { datetime_t t; rtc_get_datetime(&t); mp_obj_t tuple[8] = { @@ -46,7 +46,7 @@ STATIC mp_obj_t mp_utime_localtime_get(void) { } // Return the number of seconds since the Epoch. -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { datetime_t t; rtc_get_datetime(&t); return mp_obj_new_int_from_ull(timeutils_seconds_since_epoch(t.year, t.month, t.day, t.hour, t.min, t.sec)); diff --git a/ports/rp2/mphalport.c b/ports/rp2/mphalport.c index 84a34b2a405..52d55198b7d 100644 --- a/ports/rp2/mphalport.c +++ b/ports/rp2/mphalport.c @@ -109,7 +109,7 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { } #endif #if MICROPY_PY_OS_DUPTERM - ret |= mp_uos_dupterm_poll(poll_flags); + ret |= mp_os_dupterm_poll(poll_flags); #endif return ret; } @@ -126,7 +126,7 @@ int mp_hal_stdin_rx_chr(void) { return c; } #if MICROPY_PY_OS_DUPTERM - int dupterm_c = mp_uos_dupterm_rx_chr(); + int dupterm_c = mp_os_dupterm_rx_chr(); if (dupterm_c >= 0) { return dupterm_c; } @@ -164,7 +164,7 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { #endif #if MICROPY_PY_OS_DUPTERM - mp_uos_dupterm_tx_strn(str, len); + mp_os_dupterm_tx_strn(str, len); #endif } diff --git a/ports/samd/moduos.c b/ports/samd/moduos.c index 3404919d24b..4438bf3c7bb 100644 --- a/ports/samd/moduos.c +++ b/ports/samd/moduos.c @@ -70,7 +70,7 @@ uint32_t trng_random_u32(int delay) { #endif #if MICROPY_PY_UOS_URANDOM -STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { +STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; vstr_init_len(&vstr, n); @@ -86,22 +86,22 @@ STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { } return mp_obj_new_bytes_from_vstr(&vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_urandom_obj, mp_uos_urandom); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); #endif // MICROPY_PY_UOS_URANDOM #if MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM -bool mp_uos_dupterm_is_builtin_stream(mp_const_obj_t stream) { +bool mp_os_dupterm_is_builtin_stream(mp_const_obj_t stream) { const mp_obj_type_t *type = mp_obj_get_type(stream); return type == &machine_uart_type; } #endif #if MICROPY_PY_UOS_DUPTERM_NOTIFY -STATIC mp_obj_t mp_uos_dupterm_notify(mp_obj_t obj_in) { +STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) { (void)obj_in; for (;;) { - int c = mp_uos_dupterm_rx_chr(); + int c = mp_os_dupterm_rx_chr(); if (c < 0) { break; } @@ -109,5 +109,5 @@ STATIC mp_obj_t mp_uos_dupterm_notify(mp_obj_t obj_in) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_dupterm_notify_obj, mp_uos_dupterm_notify); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_dupterm_notify_obj, mp_os_dupterm_notify); #endif diff --git a/ports/samd/modutime.c b/ports/samd/modutime.c index db90a228226..aa5bd33609f 100644 --- a/ports/samd/modutime.c +++ b/ports/samd/modutime.c @@ -29,7 +29,7 @@ #include "modmachine.h" // Return the localtime as an 8-tuple. -STATIC mp_obj_t mp_utime_localtime_get(void) { +STATIC mp_obj_t mp_time_localtime_get(void) { timeutils_struct_time_t tm; rtc_gettime(&tm); tm.tm_wday = timeutils_calc_weekday(tm.tm_year, tm.tm_mon, tm.tm_mday); @@ -48,7 +48,7 @@ STATIC mp_obj_t mp_utime_localtime_get(void) { } // Returns the number of seconds, as an integer, since the Epoch. -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { timeutils_struct_time_t tm; rtc_gettime(&tm); return mp_obj_new_int_from_uint(timeutils_mktime( diff --git a/ports/samd/mphalport.c b/ports/samd/mphalport.c index 3dc6b70a8d9..dc38ea2964e 100644 --- a/ports/samd/mphalport.c +++ b/ports/samd/mphalport.c @@ -167,7 +167,7 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { } #if MICROPY_PY_OS_DUPTERM - ret |= mp_uos_dupterm_poll(poll_flags); + ret |= mp_os_dupterm_poll(poll_flags); #endif return ret; } @@ -182,7 +182,7 @@ int mp_hal_stdin_rx_chr(void) { } #if MICROPY_PY_OS_DUPTERM - int dupterm_c = mp_uos_dupterm_rx_chr(); + int dupterm_c = mp_os_dupterm_rx_chr(); if (dupterm_c >= 0) { return dupterm_c; } @@ -212,6 +212,6 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { } } #if MICROPY_PY_OS_DUPTERM - mp_uos_dupterm_tx_strn(str, len); + mp_os_dupterm_tx_strn(str, len); #endif } diff --git a/ports/stm32/modpyb.c b/ports/stm32/modpyb.c index b148898f164..88eafafb0aa 100644 --- a/ports/stm32/modpyb.c +++ b/ports/stm32/modpyb.c @@ -178,13 +178,13 @@ STATIC const mp_rom_map_elem_t pyb_module_globals_table[] = { #endif #if MICROPY_PY_PYB_LEGACY - { MP_ROM_QSTR(MP_QSTR_millis), MP_ROM_PTR(&mp_utime_ticks_ms_obj) }, + { MP_ROM_QSTR(MP_QSTR_millis), MP_ROM_PTR(&mp_time_ticks_ms_obj) }, { MP_ROM_QSTR(MP_QSTR_elapsed_millis), MP_ROM_PTR(&pyb_elapsed_millis_obj) }, - { MP_ROM_QSTR(MP_QSTR_micros), MP_ROM_PTR(&mp_utime_ticks_us_obj) }, + { MP_ROM_QSTR(MP_QSTR_micros), MP_ROM_PTR(&mp_time_ticks_us_obj) }, { MP_ROM_QSTR(MP_QSTR_elapsed_micros), MP_ROM_PTR(&pyb_elapsed_micros_obj) }, - { MP_ROM_QSTR(MP_QSTR_delay), MP_ROM_PTR(&mp_utime_sleep_ms_obj) }, - { MP_ROM_QSTR(MP_QSTR_udelay), MP_ROM_PTR(&mp_utime_sleep_us_obj) }, - { MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&mp_uos_sync_obj) }, + { MP_ROM_QSTR(MP_QSTR_delay), MP_ROM_PTR(&mp_time_sleep_ms_obj) }, + { MP_ROM_QSTR(MP_QSTR_udelay), MP_ROM_PTR(&mp_time_sleep_us_obj) }, + { MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&mp_os_sync_obj) }, { MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&mp_vfs_mount_obj) }, #endif diff --git a/ports/stm32/moduos.c b/ports/stm32/moduos.c index 1f41e68bdef..bfbb868e2fb 100644 --- a/ports/stm32/moduos.c +++ b/ports/stm32/moduos.c @@ -33,7 +33,7 @@ // urandom(n) // Return a bytes object with n random bytes, generated by the hardware // random number generator. -STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { +STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; vstr_init_len(&vstr, n); @@ -42,10 +42,10 @@ STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { } return mp_obj_new_bytes_from_vstr(&vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_urandom_obj, mp_uos_urandom); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); #endif -bool mp_uos_dupterm_is_builtin_stream(mp_const_obj_t stream) { +bool mp_os_dupterm_is_builtin_stream(mp_const_obj_t stream) { const mp_obj_type_t *type = mp_obj_get_type(stream); return type == &pyb_uart_type #if MICROPY_HW_ENABLE_USB @@ -54,7 +54,7 @@ bool mp_uos_dupterm_is_builtin_stream(mp_const_obj_t stream) { ; } -void mp_uos_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached) { +void mp_os_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached) { if (mp_obj_get_type(stream_detached) == &pyb_uart_type) { uart_attach_to_repl(MP_OBJ_TO_PTR(stream_detached), false); } diff --git a/ports/stm32/modutime.c b/ports/stm32/modutime.c index 4eda59f81ef..e7160cd5b2c 100644 --- a/ports/stm32/modutime.c +++ b/ports/stm32/modutime.c @@ -29,7 +29,7 @@ #include "rtc.h" // Return the localtime as an 8-tuple. -STATIC mp_obj_t mp_utime_localtime_get(void) { +STATIC mp_obj_t mp_time_localtime_get(void) { // get current date and time // note: need to call get time then get date to correctly access the registers rtc_init_finalise(); @@ -51,7 +51,7 @@ STATIC mp_obj_t mp_utime_localtime_get(void) { } // Returns the number of seconds, as an integer, since 1/1/2000. -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { // get date and time // note: need to call get time then get date to correctly access the registers rtc_init_finalise(); diff --git a/ports/stm32/mphalport.c b/ports/stm32/mphalport.c index 092d63e1bb1..727517f5bda 100644 --- a/ports/stm32/mphalport.c +++ b/ports/stm32/mphalport.c @@ -28,7 +28,7 @@ MP_WEAK uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { const mp_stream_p_t *stream_p = mp_get_stream(pyb_stdio_uart); ret = stream_p->ioctl(pyb_stdio_uart, MP_STREAM_POLL, poll_flags, &errcode); } - return ret | mp_uos_dupterm_poll(poll_flags); + return ret | mp_os_dupterm_poll(poll_flags); } MP_WEAK int mp_hal_stdin_rx_chr(void) { @@ -45,7 +45,7 @@ MP_WEAK int mp_hal_stdin_rx_chr(void) { if (MP_STATE_PORT(pyb_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(pyb_stdio_uart))) { return uart_rx_char(MP_STATE_PORT(pyb_stdio_uart)); } - int dupterm_c = mp_uos_dupterm_rx_chr(); + int dupterm_c = mp_os_dupterm_rx_chr(); if (dupterm_c >= 0) { return dupterm_c; } @@ -60,7 +60,7 @@ MP_WEAK void mp_hal_stdout_tx_strn(const char *str, size_t len) { #if 0 && defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD lcd_print_strn(str, len); #endif - mp_uos_dupterm_tx_strn(str, len); + mp_os_dupterm_tx_strn(str, len); } #if __CORTEX_M >= 0x03 diff --git a/ports/stm32/portmodules.h b/ports/stm32/portmodules.h index f6edef39877..87f97f31700 100644 --- a/ports/stm32/portmodules.h +++ b/ports/stm32/portmodules.h @@ -28,13 +28,13 @@ extern const mp_obj_module_t pyb_module; extern const mp_obj_module_t stm_module; -extern const mp_obj_module_t mp_module_usocket; +extern const mp_obj_module_t mp_module_socket; // additional helper functions exported by the modules MP_DECLARE_CONST_FUN_OBJ_1(time_sleep_ms_obj); MP_DECLARE_CONST_FUN_OBJ_1(time_sleep_us_obj); -MP_DECLARE_CONST_FUN_OBJ_0(mp_uos_sync_obj); +MP_DECLARE_CONST_FUN_OBJ_0(mp_os_sync_obj); #endif // MICROPY_INCLUDED_STM32_PORTMODULES_H diff --git a/ports/unix/main.c b/ports/unix/main.c index fc0f6da7b81..392ce59dded 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -73,7 +73,7 @@ STATIC void stderr_print_strn(void *env, const char *str, size_t len) { (void)env; ssize_t ret; MP_HAL_RETRY_SYSCALL(ret, write(STDERR_FILENO, str, len), {}); - mp_uos_dupterm_tx_strn(str, len); + mp_os_dupterm_tx_strn(str, len); } const mp_print_t mp_stderr_print = {NULL, stderr_print_strn}; diff --git a/ports/unix/moduos.c b/ports/unix/moduos.c index e44ceb677b5..1d5e2afef4a 100644 --- a/ports/unix/moduos.c +++ b/ports/unix/moduos.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "py/mphal.h" -STATIC mp_obj_t mp_uos_getenv(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t mp_os_getenv(size_t n_args, const mp_obj_t *args) { const char *s = getenv(mp_obj_str_get_str(args[0])); if (s == NULL) { if (n_args == 2) { @@ -42,9 +42,9 @@ STATIC mp_obj_t mp_uos_getenv(size_t n_args, const mp_obj_t *args) { } return mp_obj_new_str(s, strlen(s)); } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_getenv_obj, 1, 2, mp_uos_getenv); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_getenv_obj, 1, 2, mp_os_getenv); -STATIC mp_obj_t mp_uos_putenv(mp_obj_t key_in, mp_obj_t value_in) { +STATIC mp_obj_t mp_os_putenv(mp_obj_t key_in, mp_obj_t value_in) { const char *key = mp_obj_str_get_str(key_in); const char *value = mp_obj_str_get_str(value_in); int ret; @@ -60,9 +60,9 @@ STATIC mp_obj_t mp_uos_putenv(mp_obj_t key_in, mp_obj_t value_in) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_uos_putenv_obj, mp_uos_putenv); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_os_putenv_obj, mp_os_putenv); -STATIC mp_obj_t mp_uos_unsetenv(mp_obj_t key_in) { +STATIC mp_obj_t mp_os_unsetenv(mp_obj_t key_in) { const char *key = mp_obj_str_get_str(key_in); int ret; @@ -77,9 +77,9 @@ STATIC mp_obj_t mp_uos_unsetenv(mp_obj_t key_in) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_unsetenv_obj, mp_uos_unsetenv); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_unsetenv_obj, mp_os_unsetenv); -STATIC mp_obj_t mp_uos_system(mp_obj_t cmd_in) { +STATIC mp_obj_t mp_os_system(mp_obj_t cmd_in) { const char *cmd = mp_obj_str_get_str(cmd_in); MP_THREAD_GIL_EXIT(); @@ -90,18 +90,18 @@ STATIC mp_obj_t mp_uos_system(mp_obj_t cmd_in) { return MP_OBJ_NEW_SMALL_INT(r); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_system_obj, mp_uos_system); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_system_obj, mp_os_system); -STATIC mp_obj_t mp_uos_urandom(mp_obj_t num) { +STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; vstr_init_len(&vstr, n); mp_hal_get_random(n, vstr.buf); return mp_obj_new_bytes_from_vstr(&vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_uos_urandom_obj, mp_uos_urandom); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); -STATIC mp_obj_t mp_uos_errno(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t mp_os_errno(size_t n_args, const mp_obj_t *args) { if (n_args == 0) { return MP_OBJ_NEW_SMALL_INT(errno); } @@ -109,4 +109,4 @@ STATIC mp_obj_t mp_uos_errno(size_t n_args, const mp_obj_t *args) { errno = mp_obj_get_int(args[0]); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_errno_obj, 0, 1, mp_uos_errno); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_errno_obj, 0, 1, mp_os_errno); diff --git a/ports/unix/moduselect.c b/ports/unix/moduselect.c index 9b205d333fb..9f7f452a129 100644 --- a/ports/unix/moduselect.c +++ b/ports/unix/moduselect.c @@ -346,11 +346,11 @@ STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_table); -const mp_obj_module_t mp_module_uselect = { +const mp_obj_module_t mp_module_select = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; -MP_REGISTER_MODULE(MP_QSTR_select, mp_module_uselect); +MP_REGISTER_MODULE(MP_QSTR_select, mp_module_select); #endif // MICROPY_PY_USELECT_POSIX diff --git a/ports/unix/modutime.c b/ports/unix/modutime.c index dade99295d5..26c2fbdb900 100644 --- a/ports/unix/modutime.c +++ b/ports/unix/modutime.c @@ -61,7 +61,7 @@ static inline int msec_sleep_tv(struct timeval *tv) { #error Unsupported clock() implementation #endif -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { #if MICROPY_PY_BUILTINS_FLOAT && MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE struct timeval tv; gettimeofday(&tv, NULL); @@ -85,7 +85,7 @@ STATIC mp_obj_t mod_time_clock(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_time_clock_obj, mod_time_clock); -STATIC mp_obj_t mp_utime_sleep(mp_obj_t arg) { +STATIC mp_obj_t mp_time_sleep(mp_obj_t arg) { #if MICROPY_PY_BUILTINS_FLOAT struct timeval tv; mp_float_t val = mp_obj_get_float(arg); diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index 8eafb6119be..0588e100d6c 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -184,7 +184,7 @@ void mp_unix_mark_exec(void); #ifdef MICROPY_PY_URANDOM_SEED_INIT_FUNC #include void mp_hal_get_random(size_t n, void *buf); -static inline unsigned long mp_urandom_seed_init(void) { +static inline unsigned long mp_random_seed_init(void) { unsigned long r; mp_hal_get_random(sizeof(r), &r); return r; diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c index 6f2def89033..5478b69ad41 100644 --- a/ports/unix/unix_mphal.c +++ b/ports/unix/unix_mphal.c @@ -187,7 +187,7 @@ main_term:; void mp_hal_stdout_tx_strn(const char *str, size_t len) { ssize_t ret; MP_HAL_RETRY_SYSCALL(ret, write(STDOUT_FILENO, str, len), {}); - mp_uos_dupterm_tx_strn(str, len); + mp_os_dupterm_tx_strn(str, len); } // cooked is same as uncooked because the terminal does some postprocessing diff --git a/ports/unix/variants/mpconfigvariant_common.h b/ports/unix/variants/mpconfigvariant_common.h index e4e0c0c5d3b..9a8a524a226 100644 --- a/ports/unix/variants/mpconfigvariant_common.h +++ b/ports/unix/variants/mpconfigvariant_common.h @@ -58,7 +58,7 @@ #endif // Seed random on import. -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (mp_urandom_seed_init()) +#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (mp_random_seed_init()) // Allow exception details in low-memory conditions. #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1) diff --git a/ports/zephyr/modusocket.c b/ports/zephyr/modusocket.c index 98dff7e8e80..c3356189ab7 100644 --- a/ports/zephyr/modusocket.c +++ b/ports/zephyr/modusocket.c @@ -448,7 +448,7 @@ STATIC mp_obj_t pkt_get_info(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(pkt_get_info_obj, pkt_get_info); -STATIC const mp_rom_map_elem_t mp_module_usocket_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_socket_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, // objects { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socket_type) }, @@ -466,13 +466,13 @@ STATIC const mp_rom_map_elem_t mp_module_usocket_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_pkt_get_info), MP_ROM_PTR(&pkt_get_info_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(mp_module_usocket_globals, mp_module_usocket_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_socket_globals, mp_module_socket_globals_table); -const mp_obj_module_t mp_module_usocket = { +const mp_obj_module_t mp_module_socket = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_usocket_globals, + .globals = (mp_obj_dict_t *)&mp_module_socket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket); +MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); #endif // MICROPY_PY_USOCKET diff --git a/ports/zephyr/modutime.c b/ports/zephyr/modutime.c index c02460ba018..65ba1e6e691 100644 --- a/ports/zephyr/modutime.c +++ b/ports/zephyr/modutime.c @@ -29,7 +29,7 @@ #include "py/obj.h" -STATIC mp_obj_t mp_utime_time_get(void) { +STATIC mp_obj_t mp_time_time_get(void) { /* The absence of FP support is deliberate. The Zephyr port uses * single precision floats so the fraction component will start to * lose precision on devices with a long uptime. diff --git a/py/builtin.h b/py/builtin.h index 7232142b77b..81d0789802b 100644 --- a/py/builtin.h +++ b/py/builtin.h @@ -133,7 +133,7 @@ extern const mp_obj_module_t mp_module_builtins; extern const mp_obj_module_t mp_module_sys; // Modules needed by the parser when MICROPY_COMP_MODULE_CONST is enabled. -extern const mp_obj_module_t mp_module_uerrno; +extern const mp_obj_module_t mp_module_errno; extern const mp_obj_module_t mp_module_uctypes; extern const mp_obj_module_t mp_module_machine; diff --git a/py/modarray.c b/py/modarray.c index c91e92f798b..cfed0fbb59c 100644 --- a/py/modarray.c +++ b/py/modarray.c @@ -35,11 +35,11 @@ STATIC const mp_rom_map_elem_t mp_module_array_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table); -const mp_obj_module_t mp_module_uarray = { +const mp_obj_module_t mp_module_array = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_array_globals, }; -MP_REGISTER_MODULE(MP_QSTR_array, mp_module_uarray); +MP_REGISTER_MODULE(MP_QSTR_array, mp_module_array); #endif diff --git a/py/modstruct.c b/py/modstruct.c index 78c7d53e4bb..e908c73e1d9 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -261,11 +261,11 @@ STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table); -const mp_obj_module_t mp_module_ustruct = { +const mp_obj_module_t mp_module_struct = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_struct_globals, }; -MP_REGISTER_MODULE(MP_QSTR_struct, mp_module_ustruct); +MP_REGISTER_MODULE(MP_QSTR_struct, mp_module_struct); #endif diff --git a/py/moduerrno.c b/py/moduerrno.c index e197f921e15..ed172ae4d6e 100644 --- a/py/moduerrno.c +++ b/py/moduerrno.c @@ -81,7 +81,7 @@ STATIC const mp_obj_dict_t errorcode_dict = { }; #endif -STATIC const mp_rom_map_elem_t mp_module_uerrno_globals_table[] = { +STATIC const mp_rom_map_elem_t mp_module_errno_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_errno) }, #if MICROPY_PY_UERRNO_ERRORCODE { MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) }, @@ -92,14 +92,14 @@ STATIC const mp_rom_map_elem_t mp_module_uerrno_globals_table[] = { #undef X }; -STATIC MP_DEFINE_CONST_DICT(mp_module_uerrno_globals, mp_module_uerrno_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module_errno_globals, mp_module_errno_globals_table); -const mp_obj_module_t mp_module_uerrno = { +const mp_obj_module_t mp_module_errno = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_uerrno_globals, + .globals = (mp_obj_dict_t *)&mp_module_errno_globals, }; -MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_uerrno); +MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_errno); qstr mp_errno_to_str(mp_obj_t errno_val) { #if MICROPY_PY_UERRNO_ERRORCODE @@ -112,9 +112,9 @@ qstr mp_errno_to_str(mp_obj_t errno_val) { } #else // We don't have the errorcode dict so do a simple search in the modules dict - for (size_t i = 0; i < MP_ARRAY_SIZE(mp_module_uerrno_globals_table); ++i) { - if (errno_val == mp_module_uerrno_globals_table[i].value) { - return MP_OBJ_QSTR_VALUE(mp_module_uerrno_globals_table[i].key); + for (size_t i = 0; i < MP_ARRAY_SIZE(mp_module_errno_globals_table); ++i) { + if (errno_val == mp_module_errno_globals_table[i].value) { + return MP_OBJ_QSTR_VALUE(mp_module_errno_globals_table[i].key); } } return MP_QSTRnull; diff --git a/py/parse.c b/py/parse.c index 86198224fda..a271aa0ea35 100644 --- a/py/parse.c +++ b/py/parse.c @@ -637,7 +637,7 @@ STATIC void push_result_token(parser_t *parser, uint8_t rule_id) { #if MICROPY_COMP_MODULE_CONST STATIC const mp_rom_map_elem_t mp_constants_table[] = { #if MICROPY_PY_UERRNO - { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, + { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_errno) }, #endif #if MICROPY_PY_UCTYPES { MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) }, From 7f5d5c72718af773db751269c6ae14037b9c0727 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 18 Aug 2022 14:49:57 +1000 Subject: [PATCH 0011/4300] all: Rename mod_umodule*, ^umodule* to remove the "u" prefix. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- examples/natmod/uheapq/uheapq.c | 6 +- examples/natmod/urandom/urandom.c | 14 +-- examples/natmod/uzlib/uzlib.c | 2 +- extmod/modlwip.c | 2 +- extmod/moducryptolib.c | 26 +++--- extmod/moduhashlib.c | 138 ++++++++++++++--------------- extmod/moduheapq.c | 38 ++++---- extmod/modujson.c | 50 +++++------ extmod/modurandom.c | 50 +++++------ extmod/modure.c | 6 +- extmod/modusocket.c | 10 +-- extmod/modussl_axtls.c | 48 +++++----- extmod/modussl_mbedtls.c | 16 ++-- extmod/modutimeq.c | 74 ++++++++-------- extmod/moduwebsocket.c | 6 +- extmod/moduzlib.c | 10 +-- ports/cc3200/mods/modusocket.c | 16 ++-- ports/cc3200/mpconfigport.h | 2 +- ports/esp32/main.c | 2 +- ports/esp32/modnetwork.h | 2 +- ports/esp32/modsocket.c | 38 ++++---- ports/esp32/mpconfigport.h | 2 +- ports/nrf/main.c | 8 +- ports/nrf/modules/uos/microbitfs.c | 70 +++++++-------- ports/nrf/modules/uos/microbitfs.h | 14 +-- ports/nrf/modules/uos/moduos.c | 10 +-- ports/nrf/mpconfigport.h | 2 +- ports/nrf/qstrdefsport.h | 2 +- ports/renesas-ra/qstrdefsport.h | 2 +- ports/samd/modmachine.c | 2 +- ports/stm32/modpyb.c | 2 +- ports/stm32/qstrdefsport.h | 2 +- ports/stm32/rng.c | 2 +- ports/unix/coverage.c | 2 +- ports/unix/modusocket.c | 17 ++-- ports/unix/unix_mphal.c | 2 +- py/mpconfig.h | 20 ++--- 37 files changed, 357 insertions(+), 358 deletions(-) diff --git a/examples/natmod/uheapq/uheapq.c b/examples/natmod/uheapq/uheapq.c index 75f00e15cb0..ff70bef479e 100644 --- a/examples/natmod/uheapq/uheapq.c +++ b/examples/natmod/uheapq/uheapq.c @@ -8,9 +8,9 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a MP_DYNRUNTIME_INIT_ENTRY mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_heapq)); - mp_store_global(MP_QSTR_heappush, MP_OBJ_FROM_PTR(&mod_uheapq_heappush_obj)); - mp_store_global(MP_QSTR_heappop, MP_OBJ_FROM_PTR(&mod_uheapq_heappop_obj)); - mp_store_global(MP_QSTR_heapify, MP_OBJ_FROM_PTR(&mod_uheapq_heapify_obj)); + mp_store_global(MP_QSTR_heappush, MP_OBJ_FROM_PTR(&mod_heapq_heappush_obj)); + mp_store_global(MP_QSTR_heappop, MP_OBJ_FROM_PTR(&mod_heapq_heappop_obj)); + mp_store_global(MP_QSTR_heapify, MP_OBJ_FROM_PTR(&mod_heapq_heapify_obj)); MP_DYNRUNTIME_INIT_EXIT } diff --git a/examples/natmod/urandom/urandom.c b/examples/natmod/urandom/urandom.c index bb41bf3f8ee..0c4e88c77e7 100644 --- a/examples/natmod/urandom/urandom.c +++ b/examples/natmod/urandom/urandom.c @@ -17,15 +17,15 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a yasmarang_d = 233; mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_random)); - mp_store_global(MP_QSTR_getrandbits, MP_OBJ_FROM_PTR(&mod_urandom_getrandbits_obj)); - mp_store_global(MP_QSTR_seed, MP_OBJ_FROM_PTR(&mod_urandom_seed_obj)); + mp_store_global(MP_QSTR_getrandbits, MP_OBJ_FROM_PTR(&mod_random_getrandbits_obj)); + mp_store_global(MP_QSTR_seed, MP_OBJ_FROM_PTR(&mod_random_seed_obj)); #if MICROPY_PY_URANDOM_EXTRA_FUNCS - mp_store_global(MP_QSTR_randrange, MP_OBJ_FROM_PTR(&mod_urandom_randrange_obj)); - mp_store_global(MP_QSTR_randint, MP_OBJ_FROM_PTR(&mod_urandom_randint_obj)); - mp_store_global(MP_QSTR_choice, MP_OBJ_FROM_PTR(&mod_urandom_choice_obj)); + mp_store_global(MP_QSTR_randrange, MP_OBJ_FROM_PTR(&mod_random_randrange_obj)); + mp_store_global(MP_QSTR_randint, MP_OBJ_FROM_PTR(&mod_random_randint_obj)); + mp_store_global(MP_QSTR_choice, MP_OBJ_FROM_PTR(&mod_random_choice_obj)); #if MICROPY_PY_BUILTINS_FLOAT - mp_store_global(MP_QSTR_random, MP_OBJ_FROM_PTR(&mod_urandom_random_obj)); - mp_store_global(MP_QSTR_uniform, MP_OBJ_FROM_PTR(&mod_urandom_uniform_obj)); + mp_store_global(MP_QSTR_random, MP_OBJ_FROM_PTR(&mod_random_random_obj)); + mp_store_global(MP_QSTR_uniform, MP_OBJ_FROM_PTR(&mod_random_uniform_obj)); #endif #endif diff --git a/examples/natmod/uzlib/uzlib.c b/examples/natmod/uzlib/uzlib.c index 06b24f4b818..ea21235102d 100644 --- a/examples/natmod/uzlib/uzlib.c +++ b/examples/natmod/uzlib/uzlib.c @@ -28,7 +28,7 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a MP_OBJ_TYPE_SET_SLOT(&decompio_type, locals_dict, (void*)&decompio_locals_dict, 2); mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_zlib)); - mp_store_global(MP_QSTR_decompress, MP_OBJ_FROM_PTR(&mod_uzlib_decompress_obj)); + mp_store_global(MP_QSTR_decompress, MP_OBJ_FROM_PTR(&mod_zlib_decompress_obj)); mp_store_global(MP_QSTR_DecompIO, MP_OBJ_FROM_PTR(&decompio_type)); MP_DYNRUNTIME_INIT_EXIT diff --git a/extmod/modlwip.c b/extmod/modlwip.c index 19df1ea5030..c66a1de1961 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -1801,7 +1801,7 @@ const mp_obj_module_t mp_module_lwip = { MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip); -// On LWIP-ports, this is the usocket module (replaces extmod/modusocket.c). +// On LWIP-ports, this is the socket module (replaces extmod/modusocket.c). MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_lwip); MP_REGISTER_ROOT_POINTER(mp_obj_t lwip_slip_stream); diff --git a/extmod/moducryptolib.c b/extmod/moducryptolib.c index e727f50548a..0c9701024ee 100644 --- a/extmod/moducryptolib.c +++ b/extmod/moducryptolib.c @@ -211,7 +211,7 @@ STATIC void aes_process_ctr_impl(AES_CTX_IMPL *ctx, const uint8_t *in, uint8_t * #endif -STATIC mp_obj_t ucryptolib_aes_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t cryptolib_aes_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 2, 3, false); const mp_int_t block_mode = mp_obj_get_int(args[1]); @@ -332,33 +332,33 @@ STATIC mp_obj_t aes_process(size_t n_args, const mp_obj_t *args, bool encrypt) { return mp_obj_new_bytes_from_vstr(&vstr); } -STATIC mp_obj_t ucryptolib_aes_encrypt(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t cryptolib_aes_encrypt(size_t n_args, const mp_obj_t *args) { return aes_process(n_args, args, true); } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ucryptolib_aes_encrypt_obj, 2, 3, ucryptolib_aes_encrypt); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(cryptolib_aes_encrypt_obj, 2, 3, cryptolib_aes_encrypt); -STATIC mp_obj_t ucryptolib_aes_decrypt(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t cryptolib_aes_decrypt(size_t n_args, const mp_obj_t *args) { return aes_process(n_args, args, false); } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ucryptolib_aes_decrypt_obj, 2, 3, ucryptolib_aes_decrypt); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(cryptolib_aes_decrypt_obj, 2, 3, cryptolib_aes_decrypt); -STATIC const mp_rom_map_elem_t ucryptolib_aes_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_encrypt), MP_ROM_PTR(&ucryptolib_aes_encrypt_obj) }, - { MP_ROM_QSTR(MP_QSTR_decrypt), MP_ROM_PTR(&ucryptolib_aes_decrypt_obj) }, +STATIC const mp_rom_map_elem_t cryptolib_aes_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_encrypt), MP_ROM_PTR(&cryptolib_aes_encrypt_obj) }, + { MP_ROM_QSTR(MP_QSTR_decrypt), MP_ROM_PTR(&cryptolib_aes_decrypt_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(ucryptolib_aes_locals_dict, ucryptolib_aes_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(cryptolib_aes_locals_dict, cryptolib_aes_locals_dict_table); STATIC MP_DEFINE_CONST_OBJ_TYPE( - ucryptolib_aes_type, + cryptolib_aes_type, MP_QSTR_aes, MP_TYPE_FLAG_NONE, - make_new, ucryptolib_aes_make_new, - locals_dict, &ucryptolib_aes_locals_dict + make_new, cryptolib_aes_make_new, + locals_dict, &cryptolib_aes_locals_dict ); STATIC const mp_rom_map_elem_t mp_module_cryptolib_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cryptolib) }, - { MP_ROM_QSTR(MP_QSTR_aes), MP_ROM_PTR(&ucryptolib_aes_type) }, + { MP_ROM_QSTR(MP_QSTR_aes), MP_ROM_PTR(&cryptolib_aes_type) }, #if MICROPY_PY_UCRYPTOLIB_CONSTS { MP_ROM_QSTR(MP_QSTR_MODE_ECB), MP_ROM_INT(UCRYPTOLIB_MODE_ECB) }, { MP_ROM_QSTR(MP_QSTR_MODE_CBC), MP_ROM_INT(UCRYPTOLIB_MODE_CBC) }, diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index ef1a29fc789..0e01b4f27f9 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -64,14 +64,14 @@ typedef struct _mp_obj_hash_t { uintptr_t state[0]; // must be aligned to a machine word } mp_obj_hash_t; -static void uhashlib_ensure_not_final(mp_obj_hash_t *self) { +static void hashlib_ensure_not_final(mp_obj_hash_t *self) { if (self->final) { mp_raise_ValueError(MP_ERROR_TEXT("hash is final")); } } #if MICROPY_PY_UHASHLIB_SHA256 -STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg); +STATIC mp_obj_t hashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg); #if MICROPY_SSL_MBEDTLS @@ -81,30 +81,30 @@ STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg); #define mbedtls_sha256_finish_ret mbedtls_sha256_finish #endif -STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t hashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_hash_t *o = mp_obj_malloc_var(mp_obj_hash_t, char, sizeof(mbedtls_sha256_context), type); o->final = false; mbedtls_sha256_init((mbedtls_sha256_context *)&o->state); mbedtls_sha256_starts_ret((mbedtls_sha256_context *)&o->state, 0); if (n_args == 1) { - uhashlib_sha256_update(MP_OBJ_FROM_PTR(o), args[0]); + hashlib_sha256_update(MP_OBJ_FROM_PTR(o), args[0]); } return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) { +STATIC mp_obj_t hashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); mp_buffer_info_t bufinfo; mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); mbedtls_sha256_update_ret((mbedtls_sha256_context *)&self->state, bufinfo.buf, bufinfo.len); return mp_const_none; } -STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) { +STATIC mp_obj_t hashlib_sha256_digest(mp_obj_t self_in) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); self->final = true; vstr_t vstr; vstr_init_len(&vstr, 32); @@ -116,29 +116,29 @@ STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) { #include "lib/crypto-algorithms/sha256.c" -STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t hashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_hash_t *o = mp_obj_malloc_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX), type); o->final = false; sha256_init((CRYAL_SHA256_CTX *)o->state); if (n_args == 1) { - uhashlib_sha256_update(MP_OBJ_FROM_PTR(o), args[0]); + hashlib_sha256_update(MP_OBJ_FROM_PTR(o), args[0]); } return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) { +STATIC mp_obj_t hashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); mp_buffer_info_t bufinfo; mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); sha256_update((CRYAL_SHA256_CTX *)self->state, bufinfo.buf, bufinfo.len); return mp_const_none; } -STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) { +STATIC mp_obj_t hashlib_sha256_digest(mp_obj_t self_in) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); self->final = true; vstr_t vstr; vstr_init_len(&vstr, SHA256_BLOCK_SIZE); @@ -147,52 +147,52 @@ STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) { } #endif -STATIC MP_DEFINE_CONST_FUN_OBJ_2(uhashlib_sha256_update_obj, uhashlib_sha256_update); -STATIC MP_DEFINE_CONST_FUN_OBJ_1(uhashlib_sha256_digest_obj, uhashlib_sha256_digest); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(hashlib_sha256_update_obj, hashlib_sha256_update); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(hashlib_sha256_digest_obj, hashlib_sha256_digest); -STATIC const mp_rom_map_elem_t uhashlib_sha256_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&uhashlib_sha256_update_obj) }, - { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&uhashlib_sha256_digest_obj) }, +STATIC const mp_rom_map_elem_t hashlib_sha256_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&hashlib_sha256_update_obj) }, + { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&hashlib_sha256_digest_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(uhashlib_sha256_locals_dict, uhashlib_sha256_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(hashlib_sha256_locals_dict, hashlib_sha256_locals_dict_table); STATIC MP_DEFINE_CONST_OBJ_TYPE( - uhashlib_sha256_type, + hashlib_sha256_type, MP_QSTR_sha256, MP_TYPE_FLAG_NONE, make_new, uhashlib_sha256_make_new, - locals_dict, &uhashlib_sha256_locals_dict + locals_dict, &hashlib_sha256_locals_dict ); #endif #if MICROPY_PY_UHASHLIB_SHA1 -STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg); +STATIC mp_obj_t hashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg); #if MICROPY_SSL_AXTLS -STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t hashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_hash_t *o = mp_obj_malloc_var(mp_obj_hash_t, char, sizeof(SHA1_CTX), type); o->final = false; SHA1_Init((SHA1_CTX *)o->state); if (n_args == 1) { - uhashlib_sha1_update(MP_OBJ_FROM_PTR(o), args[0]); + hashlib_sha1_update(MP_OBJ_FROM_PTR(o), args[0]); } return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg) { +STATIC mp_obj_t hashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); mp_buffer_info_t bufinfo; mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); SHA1_Update((SHA1_CTX *)self->state, bufinfo.buf, bufinfo.len); return mp_const_none; } -STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) { +STATIC mp_obj_t hashlib_sha1_digest(mp_obj_t self_in) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); self->final = true; vstr_t vstr; vstr_init_len(&vstr, SHA1_SIZE); @@ -209,30 +209,30 @@ STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) { #define mbedtls_sha1_finish_ret mbedtls_sha1_finish #endif -STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t hashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_hash_t *o = mp_obj_malloc_var(mp_obj_hash_t, char, sizeof(mbedtls_sha1_context), type); o->final = false; mbedtls_sha1_init((mbedtls_sha1_context *)o->state); mbedtls_sha1_starts_ret((mbedtls_sha1_context *)o->state); if (n_args == 1) { - uhashlib_sha1_update(MP_OBJ_FROM_PTR(o), args[0]); + hashlib_sha1_update(MP_OBJ_FROM_PTR(o), args[0]); } return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg) { +STATIC mp_obj_t hashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); mp_buffer_info_t bufinfo; mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); mbedtls_sha1_update_ret((mbedtls_sha1_context *)self->state, bufinfo.buf, bufinfo.len); return mp_const_none; } -STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) { +STATIC mp_obj_t hashlib_sha1_digest(mp_obj_t self_in) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); self->final = true; vstr_t vstr; vstr_init_len(&vstr, 20); @@ -242,51 +242,51 @@ STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) { } #endif -STATIC MP_DEFINE_CONST_FUN_OBJ_2(uhashlib_sha1_update_obj, uhashlib_sha1_update); -STATIC MP_DEFINE_CONST_FUN_OBJ_1(uhashlib_sha1_digest_obj, uhashlib_sha1_digest); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(hashlib_sha1_update_obj, hashlib_sha1_update); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(hashlib_sha1_digest_obj, hashlib_sha1_digest); -STATIC const mp_rom_map_elem_t uhashlib_sha1_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&uhashlib_sha1_update_obj) }, - { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&uhashlib_sha1_digest_obj) }, +STATIC const mp_rom_map_elem_t hashlib_sha1_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&hashlib_sha1_update_obj) }, + { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&hashlib_sha1_digest_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(uhashlib_sha1_locals_dict, uhashlib_sha1_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(hashlib_sha1_locals_dict, hashlib_sha1_locals_dict_table); STATIC MP_DEFINE_CONST_OBJ_TYPE( - uhashlib_sha1_type, + hashlib_sha1_type, MP_QSTR_sha1, MP_TYPE_FLAG_NONE, - make_new, uhashlib_sha1_make_new, - locals_dict, &uhashlib_sha1_locals_dict + make_new, hashlib_sha1_make_new, + locals_dict, &hashlib_sha1_locals_dict ); #endif #if MICROPY_PY_UHASHLIB_MD5 -STATIC mp_obj_t uhashlib_md5_update(mp_obj_t self_in, mp_obj_t arg); +STATIC mp_obj_t hashlib_md5_update(mp_obj_t self_in, mp_obj_t arg); #if MICROPY_SSL_AXTLS -STATIC mp_obj_t uhashlib_md5_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t hashlib_md5_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_hash_t *o = mp_obj_malloc_var(mp_obj_hash_t, char, sizeof(MD5_CTX), type); o->final = false; MD5_Init((MD5_CTX *)o->state); if (n_args == 1) { - uhashlib_md5_update(MP_OBJ_FROM_PTR(o), args[0]); + hashlib_md5_update(MP_OBJ_FROM_PTR(o), args[0]); } return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t uhashlib_md5_update(mp_obj_t self_in, mp_obj_t arg) { +STATIC mp_obj_t hashlib_md5_update(mp_obj_t self_in, mp_obj_t arg) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); mp_buffer_info_t bufinfo; mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); MD5_Update((MD5_CTX *)self->state, bufinfo.buf, bufinfo.len); return mp_const_none; } -STATIC mp_obj_t uhashlib_md5_digest(mp_obj_t self_in) { +STATIC mp_obj_t hashlib_md5_digest(mp_obj_t self_in) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); self->final = true; vstr_t vstr; vstr_init_len(&vstr, MD5_SIZE); @@ -303,30 +303,30 @@ STATIC mp_obj_t uhashlib_md5_digest(mp_obj_t self_in) { #define mbedtls_md5_finish_ret mbedtls_md5_finish #endif -STATIC mp_obj_t uhashlib_md5_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t hashlib_md5_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_hash_t *o = mp_obj_malloc_var(mp_obj_hash_t, char, sizeof(mbedtls_md5_context), type); o->final = false; mbedtls_md5_init((mbedtls_md5_context *)o->state); mbedtls_md5_starts_ret((mbedtls_md5_context *)o->state); if (n_args == 1) { - uhashlib_md5_update(MP_OBJ_FROM_PTR(o), args[0]); + hashlib_md5_update(MP_OBJ_FROM_PTR(o), args[0]); } return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t uhashlib_md5_update(mp_obj_t self_in, mp_obj_t arg) { +STATIC mp_obj_t hashlib_md5_update(mp_obj_t self_in, mp_obj_t arg) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); mp_buffer_info_t bufinfo; mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); mbedtls_md5_update_ret((mbedtls_md5_context *)self->state, bufinfo.buf, bufinfo.len); return mp_const_none; } -STATIC mp_obj_t uhashlib_md5_digest(mp_obj_t self_in) { +STATIC mp_obj_t hashlib_md5_digest(mp_obj_t self_in) { mp_obj_hash_t *self = MP_OBJ_TO_PTR(self_in); - uhashlib_ensure_not_final(self); + hashlib_ensure_not_final(self); self->final = true; vstr_t vstr; vstr_init_len(&vstr, 16); @@ -336,34 +336,34 @@ STATIC mp_obj_t uhashlib_md5_digest(mp_obj_t self_in) { } #endif // MICROPY_SSL_MBEDTLS -STATIC MP_DEFINE_CONST_FUN_OBJ_2(uhashlib_md5_update_obj, uhashlib_md5_update); -STATIC MP_DEFINE_CONST_FUN_OBJ_1(uhashlib_md5_digest_obj, uhashlib_md5_digest); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(hashlib_md5_update_obj, hashlib_md5_update); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(hashlib_md5_digest_obj, hashlib_md5_digest); -STATIC const mp_rom_map_elem_t uhashlib_md5_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&uhashlib_md5_update_obj) }, - { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&uhashlib_md5_digest_obj) }, +STATIC const mp_rom_map_elem_t hashlib_md5_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&hashlib_md5_update_obj) }, + { MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&hashlib_md5_digest_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(uhashlib_md5_locals_dict, uhashlib_md5_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(hashlib_md5_locals_dict, hashlib_md5_locals_dict_table); STATIC MP_DEFINE_CONST_OBJ_TYPE( - uhashlib_md5_type, + hashlib_md5_type, MP_QSTR_md5, MP_TYPE_FLAG_NONE, - make_new, uhashlib_md5_make_new, - locals_dict, &uhashlib_md5_locals_dict + make_new, hashlib_md5_make_new, + locals_dict, &hashlib_md5_locals_dict ); #endif // MICROPY_PY_UHASHLIB_MD5 STATIC const mp_rom_map_elem_t mp_module_hashlib_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_hashlib) }, #if MICROPY_PY_UHASHLIB_SHA256 - { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&uhashlib_sha256_type) }, + { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&hashlib_sha256_type) }, #endif #if MICROPY_PY_UHASHLIB_SHA1 - { MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&uhashlib_sha1_type) }, + { MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&hashlib_sha1_type) }, #endif #if MICROPY_PY_UHASHLIB_MD5 - { MP_ROM_QSTR(MP_QSTR_md5), MP_ROM_PTR(&uhashlib_md5_type) }, + { MP_ROM_QSTR(MP_QSTR_md5), MP_ROM_PTR(&hashlib_md5_type) }, #endif }; diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c index fb6cb81182e..59277813e95 100644 --- a/extmod/moduheapq.c +++ b/extmod/moduheapq.c @@ -31,14 +31,14 @@ // the algorithm here is modelled on CPython's heapq.py -STATIC mp_obj_list_t *uheapq_get_heap(mp_obj_t heap_in) { +STATIC mp_obj_list_t *heapq_get_heap(mp_obj_t heap_in) { if (!mp_obj_is_type(heap_in, &mp_type_list)) { mp_raise_TypeError(MP_ERROR_TEXT("heap must be a list")); } return MP_OBJ_TO_PTR(heap_in); } -STATIC void uheapq_heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t pos) { +STATIC void heapq_heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t pos) { mp_obj_t item = heap->items[pos]; while (pos > start_pos) { mp_uint_t parent_pos = (pos - 1) >> 1; @@ -53,7 +53,7 @@ STATIC void uheapq_heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_ui heap->items[pos] = item; } -STATIC void uheapq_heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) { +STATIC void heapq_heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) { mp_uint_t start_pos = pos; mp_uint_t end_pos = heap->len; mp_obj_t item = heap->items[pos]; @@ -67,19 +67,19 @@ STATIC void uheapq_heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) { pos = child_pos; } heap->items[pos] = item; - uheapq_heap_siftdown(heap, start_pos, pos); + heapq_heap_siftdown(heap, start_pos, pos); } -STATIC mp_obj_t mod_uheapq_heappush(mp_obj_t heap_in, mp_obj_t item) { - mp_obj_list_t *heap = uheapq_get_heap(heap_in); +STATIC mp_obj_t mod_heapq_heappush(mp_obj_t heap_in, mp_obj_t item) { + mp_obj_list_t *heap = heapq_get_heap(heap_in); mp_obj_list_append(heap_in, item); - uheapq_heap_siftdown(heap, 0, heap->len - 1); + heapq_heap_siftdown(heap, 0, heap->len - 1); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_heapq_heappush_obj, mod_heapq_heappush); -STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) { - mp_obj_list_t *heap = uheapq_get_heap(heap_in); +STATIC mp_obj_t mod_heapq_heappop(mp_obj_t heap_in) { + mp_obj_list_t *heap = heapq_get_heap(heap_in); if (heap->len == 0) { mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("empty heap")); } @@ -88,27 +88,27 @@ STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) { heap->items[0] = heap->items[heap->len]; heap->items[heap->len] = MP_OBJ_NULL; // so we don't retain a pointer if (heap->len) { - uheapq_heap_siftup(heap, 0); + heapq_heap_siftup(heap, 0); } return item; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heappop_obj, mod_uheapq_heappop); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_heapq_heappop_obj, mod_heapq_heappop); -STATIC mp_obj_t mod_uheapq_heapify(mp_obj_t heap_in) { - mp_obj_list_t *heap = uheapq_get_heap(heap_in); +STATIC mp_obj_t mod_heapq_heapify(mp_obj_t heap_in) { + mp_obj_list_t *heap = heapq_get_heap(heap_in); for (mp_uint_t i = heap->len / 2; i > 0;) { - uheapq_heap_siftup(heap, --i); + heapq_heap_siftup(heap, --i); } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heapify_obj, mod_uheapq_heapify); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_heapq_heapify_obj, mod_heapq_heapify); #if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_rom_map_elem_t mp_module_heapq_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_heapq) }, - { MP_ROM_QSTR(MP_QSTR_heappush), MP_ROM_PTR(&mod_uheapq_heappush_obj) }, - { MP_ROM_QSTR(MP_QSTR_heappop), MP_ROM_PTR(&mod_uheapq_heappop_obj) }, - { MP_ROM_QSTR(MP_QSTR_heapify), MP_ROM_PTR(&mod_uheapq_heapify_obj) }, + { MP_ROM_QSTR(MP_QSTR_heappush), MP_ROM_PTR(&mod_heapq_heappush_obj) }, + { MP_ROM_QSTR(MP_QSTR_heappop), MP_ROM_PTR(&mod_heapq_heappop_obj) }, + { MP_ROM_QSTR(MP_QSTR_heapify), MP_ROM_PTR(&mod_heapq_heapify_obj) }, }; STATIC MP_DEFINE_CONST_DICT(mp_module_heapq_globals, mp_module_heapq_globals_table); diff --git a/extmod/modujson.c b/extmod/modujson.c index 44dd316b699..e67761e1a99 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -41,7 +41,7 @@ enum { DUMP_MODE_TO_STREAM = 2, }; -STATIC mp_obj_t mod_ujson_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, unsigned int mode) { +STATIC mp_obj_t mod_json_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, unsigned int mode) { enum { ARG_separators }; static const mp_arg_t allowed_args[] = { { MP_QSTR_separators, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} }, @@ -78,34 +78,34 @@ STATIC mp_obj_t mod_ujson_dump_helper(size_t n_args, const mp_obj_t *pos_args, m } } -STATIC mp_obj_t mod_ujson_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - return mod_ujson_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STREAM); +STATIC mp_obj_t mod_json_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + return mod_json_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STREAM); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ujson_dump_obj, 2, mod_ujson_dump); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dump_obj, 2, mod_json_dump); -STATIC mp_obj_t mod_ujson_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - return mod_ujson_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STRING); +STATIC mp_obj_t mod_json_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + return mod_json_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STRING); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ujson_dumps_obj, 1, mod_ujson_dumps); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dumps_obj, 1, mod_json_dumps); #else -STATIC mp_obj_t mod_ujson_dump(mp_obj_t obj, mp_obj_t stream) { +STATIC mp_obj_t mod_json_dump(mp_obj_t obj, mp_obj_t stream) { mp_get_stream_raise(stream, MP_STREAM_OP_WRITE); mp_print_t print = {MP_OBJ_TO_PTR(stream), mp_stream_write_adaptor}; mp_obj_print_helper(&print, obj, PRINT_JSON); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_ujson_dump_obj, mod_ujson_dump); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_json_dump_obj, mod_json_dump); -STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) { +STATIC mp_obj_t mod_json_dumps(mp_obj_t obj) { vstr_t vstr; mp_print_t print; vstr_init_print(&vstr, 8, &print); mp_obj_print_helper(&print, obj, PRINT_JSON); return mp_obj_new_str_from_utf8_vstr(&vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_dumps_obj, mod_json_dumps); #endif @@ -122,19 +122,19 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps); // strings). It does 1 pass over the input stream. It tries to be fast and // small in code size, while not using more RAM than necessary. -typedef struct _ujson_stream_t { +typedef struct _json_stream_t { mp_obj_t stream_obj; mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); int errcode; byte cur; -} ujson_stream_t; +} json_stream_t; #define S_EOF (0) // null is not allowed in json stream so is ok as EOF marker #define S_END(s) ((s).cur == S_EOF) #define S_CUR(s) ((s).cur) -#define S_NEXT(s) (ujson_stream_next(&(s))) +#define S_NEXT(s) (json_stream_next(&(s))) -STATIC byte ujson_stream_next(ujson_stream_t *s) { +STATIC byte json_stream_next(json_stream_t *s) { mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode); if (s->errcode != 0) { mp_raise_OSError(s->errcode); @@ -145,9 +145,9 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) { return s->cur; } -STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { +STATIC mp_obj_t mod_json_load(mp_obj_t stream_obj) { const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ); - ujson_stream_t s = {stream_obj, stream_p->read, 0, 0}; + json_stream_t s = {stream_obj, stream_p->read, 0, 0}; vstr_t vstr; vstr_init(&vstr, 8); mp_obj_list_t stack; // we use a list as a simple stack for nested JSON @@ -355,23 +355,23 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) { fail: mp_raise_ValueError(MP_ERROR_TEXT("syntax error in JSON")); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_load_obj, mod_ujson_load); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_load_obj, mod_json_load); -STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) { +STATIC mp_obj_t mod_json_loads(mp_obj_t obj) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(obj, &bufinfo, MP_BUFFER_READ); vstr_t vstr = {bufinfo.len, bufinfo.len, (char *)bufinfo.buf, true}; mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL}; - return mod_ujson_load(MP_OBJ_FROM_PTR(&sio)); + return mod_json_load(MP_OBJ_FROM_PTR(&sio)); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_loads_obj, mod_ujson_loads); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_loads_obj, mod_json_loads); STATIC const mp_rom_map_elem_t mp_module_json_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_json) }, - { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_ujson_dump_obj) }, - { MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_ujson_dumps_obj) }, - { MP_ROM_QSTR(MP_QSTR_load), MP_ROM_PTR(&mod_ujson_load_obj) }, - { MP_ROM_QSTR(MP_QSTR_loads), MP_ROM_PTR(&mod_ujson_loads_obj) }, + { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_json_dump_obj) }, + { MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_json_dumps_obj) }, + { MP_ROM_QSTR(MP_QSTR_load), MP_ROM_PTR(&mod_json_load_obj) }, + { MP_ROM_QSTR(MP_QSTR_loads), MP_ROM_PTR(&mod_json_loads_obj) }, }; STATIC MP_DEFINE_CONST_DICT(mp_module_json_globals, mp_module_json_globals_table); diff --git a/extmod/modurandom.c b/extmod/modurandom.c index 86e3a872c55..f69f7f41933 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -85,7 +85,7 @@ STATIC uint32_t yasmarang_randbelow(uint32_t n) { #endif -STATIC mp_obj_t mod_urandom_getrandbits(mp_obj_t num_in) { +STATIC mp_obj_t mod_random_getrandbits(mp_obj_t num_in) { int n = mp_obj_get_int(num_in); if (n > 32 || n < 0) { mp_raise_ValueError(MP_ERROR_TEXT("bits must be 32 or less")); @@ -98,9 +98,9 @@ STATIC mp_obj_t mod_urandom_getrandbits(mp_obj_t num_in) { mask >>= (32 - n); return mp_obj_new_int_from_uint(yasmarang() & mask); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_urandom_getrandbits_obj, mod_urandom_getrandbits); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_getrandbits_obj, mod_random_getrandbits); -STATIC mp_obj_t mod_urandom_seed(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) { mp_uint_t seed; if (n_args == 0 || args[0] == mp_const_none) { #ifdef MICROPY_PY_URANDOM_SEED_INIT_FUNC @@ -117,11 +117,11 @@ STATIC mp_obj_t mod_urandom_seed(size_t n_args, const mp_obj_t *args) { yasmarang_dat = 0; return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_urandom_seed_obj, 0, 1, mod_urandom_seed); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_seed_obj, 0, 1, mod_random_seed); #if MICROPY_PY_URANDOM_EXTRA_FUNCS -STATIC mp_obj_t mod_urandom_randrange(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) { mp_int_t start = mp_obj_get_int(args[0]); if (n_args == 1) { // range(stop) @@ -161,9 +161,9 @@ STATIC mp_obj_t mod_urandom_randrange(size_t n_args, const mp_obj_t *args) { error: mp_raise_ValueError(NULL); } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_urandom_randrange_obj, 1, 3, mod_urandom_randrange); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_randrange_obj, 1, 3, mod_random_randrange); -STATIC mp_obj_t mod_urandom_randint(mp_obj_t a_in, mp_obj_t b_in) { +STATIC mp_obj_t mod_random_randint(mp_obj_t a_in, mp_obj_t b_in) { mp_int_t a = mp_obj_get_int(a_in); mp_int_t b = mp_obj_get_int(b_in); if (a <= b) { @@ -172,9 +172,9 @@ STATIC mp_obj_t mod_urandom_randint(mp_obj_t a_in, mp_obj_t b_in) { mp_raise_ValueError(NULL); } } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_randint_obj, mod_urandom_randint); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_randint_obj, mod_random_randint); -STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) { +STATIC mp_obj_t mod_random_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); if (len > 0) { return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL); @@ -182,7 +182,7 @@ STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) { mp_raise_type(&mp_type_IndexError); } } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_urandom_choice_obj, mod_urandom_choice); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_choice_obj, mod_random_choice); #if MICROPY_PY_BUILTINS_FLOAT @@ -199,51 +199,51 @@ STATIC mp_float_t yasmarang_float(void) { return u.f - 1; } -STATIC mp_obj_t mod_urandom_random(void) { +STATIC mp_obj_t mod_random_random(void) { return mp_obj_new_float(yasmarang_float()); } -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_urandom_random_obj, mod_urandom_random); +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_random_random_obj, mod_random_random); -STATIC mp_obj_t mod_urandom_uniform(mp_obj_t a_in, mp_obj_t b_in) { +STATIC mp_obj_t mod_random_uniform(mp_obj_t a_in, mp_obj_t b_in) { mp_float_t a = mp_obj_get_float(a_in); mp_float_t b = mp_obj_get_float(b_in); return mp_obj_new_float(a + (b - a) * yasmarang_float()); } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_uniform_obj, mod_urandom_uniform); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_uniform_obj, mod_random_uniform); #endif #endif // MICROPY_PY_URANDOM_EXTRA_FUNCS #if SEED_ON_IMPORT -STATIC mp_obj_t mod_urandom___init__(void) { +STATIC mp_obj_t mod_random___init__(void) { // This module may be imported by more than one name so need to ensure // that it's only ever seeded once. static bool seeded = false; if (!seeded) { seeded = true; - mod_urandom_seed(0, NULL); + mod_random_seed(0, NULL); } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_urandom___init___obj, mod_urandom___init__); +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_random___init___obj, mod_random___init__); #endif #if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_rom_map_elem_t mp_module_random_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_random) }, #if SEED_ON_IMPORT - { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&mod_urandom___init___obj) }, + { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&mod_random___init___obj) }, #endif - { MP_ROM_QSTR(MP_QSTR_getrandbits), MP_ROM_PTR(&mod_urandom_getrandbits_obj) }, - { MP_ROM_QSTR(MP_QSTR_seed), MP_ROM_PTR(&mod_urandom_seed_obj) }, + { MP_ROM_QSTR(MP_QSTR_getrandbits), MP_ROM_PTR(&mod_random_getrandbits_obj) }, + { MP_ROM_QSTR(MP_QSTR_seed), MP_ROM_PTR(&mod_random_seed_obj) }, #if MICROPY_PY_URANDOM_EXTRA_FUNCS - { MP_ROM_QSTR(MP_QSTR_randrange), MP_ROM_PTR(&mod_urandom_randrange_obj) }, - { MP_ROM_QSTR(MP_QSTR_randint), MP_ROM_PTR(&mod_urandom_randint_obj) }, - { MP_ROM_QSTR(MP_QSTR_choice), MP_ROM_PTR(&mod_urandom_choice_obj) }, + { MP_ROM_QSTR(MP_QSTR_randrange), MP_ROM_PTR(&mod_random_randrange_obj) }, + { MP_ROM_QSTR(MP_QSTR_randint), MP_ROM_PTR(&mod_random_randint_obj) }, + { MP_ROM_QSTR(MP_QSTR_choice), MP_ROM_PTR(&mod_random_choice_obj) }, #if MICROPY_PY_BUILTINS_FLOAT - { MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&mod_urandom_random_obj) }, - { MP_ROM_QSTR(MP_QSTR_uniform), MP_ROM_PTR(&mod_urandom_uniform_obj) }, + { MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&mod_random_random_obj) }, + { MP_ROM_QSTR(MP_QSTR_uniform), MP_ROM_PTR(&mod_random_uniform_obj) }, #endif #endif }; diff --git a/extmod/modure.c b/extmod/modure.c index 4798f07b0be..a6fad3cf4ee 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -194,7 +194,7 @@ STATIC void re_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t mp_printf(print, "", self); } -STATIC mp_obj_t ure_exec(bool is_anchored, uint n_args, const mp_obj_t *args) { +STATIC mp_obj_t re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) { (void)n_args; mp_obj_re_t *self; if (mp_obj_is_type(args[0], (mp_obj_type_t *)&re_type)) { @@ -223,12 +223,12 @@ STATIC mp_obj_t ure_exec(bool is_anchored, uint n_args, const mp_obj_t *args) { } STATIC mp_obj_t re_match(size_t n_args, const mp_obj_t *args) { - return ure_exec(true, n_args, args); + return re_exec(true, n_args, args); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_match_obj, 2, 4, re_match); STATIC mp_obj_t re_search(size_t n_args, const mp_obj_t *args) { - return ure_exec(false, n_args, args); + return re_exec(false, n_args, args); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_search_obj, 2, 4, re_search); diff --git a/extmod/modusocket.c b/extmod/modusocket.c index 6c2b4ff06fd..c8695f10448 100644 --- a/extmod/modusocket.c +++ b/extmod/modusocket.c @@ -540,10 +540,10 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); /******************************************************************************/ -// usocket module +// socket module -// function usocket.getaddrinfo(host, port) -STATIC mp_obj_t mod_usocket_getaddrinfo(size_t n_args, const mp_obj_t *args) { +// function socket.getaddrinfo(host, port) +STATIC mp_obj_t mod_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) { size_t hlen; const char *host = mp_obj_str_get_data(args[0], &hlen); mp_int_t port = mp_obj_get_int(args[1]); @@ -613,13 +613,13 @@ STATIC mp_obj_t mod_usocket_getaddrinfo(size_t n_args, const mp_obj_t *args) { tuple->items[4] = netutils_format_inet_addr(out_ip, port, NETUTILS_BIG); return mp_obj_new_list(1, (mp_obj_t *)&tuple); } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_usocket_getaddrinfo_obj, 2, 6, mod_usocket_getaddrinfo); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_socket_getaddrinfo_obj, 2, 6, mod_socket_getaddrinfo); STATIC const mp_rom_map_elem_t mp_module_socket_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socket_type) }, - { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&mod_usocket_getaddrinfo_obj) }, + { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&mod_socket_getaddrinfo_obj) }, // class constants { MP_ROM_QSTR(MP_QSTR_AF_INET), MP_ROM_INT(MOD_NETWORK_AF_INET) }, diff --git a/extmod/modussl_axtls.c b/extmod/modussl_axtls.c index 6e490a594a0..c09059cae85 100644 --- a/extmod/modussl_axtls.c +++ b/extmod/modussl_axtls.c @@ -53,7 +53,7 @@ struct ssl_args { mp_arg_val_t do_handshake; }; -STATIC const mp_obj_type_t ussl_socket_type; +STATIC const mp_obj_type_t ssl_socket_type; // Table of error strings corresponding to SSL_xxx error codes. STATIC const char *const ssl_error_tab1[] = { @@ -84,7 +84,7 @@ STATIC const char *const ssl_error_tab2[] = { "NOT_SUPPORTED", }; -STATIC NORETURN void ussl_raise_error(int err) { +STATIC NORETURN void ssl_raise_error(int err) { MP_STATIC_ASSERT(SSL_NOT_OK - 3 == SSL_EAGAIN); MP_STATIC_ASSERT(SSL_ERROR_CONN_LOST - 18 == SSL_ERROR_NOT_SUPPORTED); @@ -117,13 +117,13 @@ STATIC NORETURN void ussl_raise_error(int err) { } -STATIC mp_obj_ssl_socket_t *ussl_socket_new(mp_obj_t sock, struct ssl_args *args) { +STATIC mp_obj_ssl_socket_t *ssl_socket_new(mp_obj_t sock, struct ssl_args *args) { #if MICROPY_PY_USSL_FINALISER mp_obj_ssl_socket_t *o = m_new_obj_with_finaliser(mp_obj_ssl_socket_t); #else mp_obj_ssl_socket_t *o = m_new_obj(mp_obj_ssl_socket_t); #endif - o->base.type = &ussl_socket_type; + o->base.type = &ssl_socket_type; o->buf = NULL; o->bytes_left = 0; o->sock = sock; @@ -175,7 +175,7 @@ STATIC mp_obj_ssl_socket_t *ussl_socket_new(mp_obj_t sock, struct ssl_args *args } else if (r == SSL_EAGAIN) { r = MP_EAGAIN; } - ussl_raise_error(r); + ssl_raise_error(r); } } @@ -184,13 +184,13 @@ STATIC mp_obj_ssl_socket_t *ussl_socket_new(mp_obj_t sock, struct ssl_args *args return o; } -STATIC void ussl_socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void ssl_socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { (void)kind; mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "<_SSLSocket %p>", self->ssl_sock); } -STATIC mp_uint_t ussl_socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { +STATIC mp_uint_t ssl_socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); if (o->ssl_sock == NULL) { @@ -239,7 +239,7 @@ STATIC mp_uint_t ussl_socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int return size; } -STATIC mp_uint_t ussl_socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { +STATIC mp_uint_t ssl_socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); if (o->ssl_sock == NULL) { @@ -251,7 +251,7 @@ STATIC mp_uint_t ussl_socket_write(mp_obj_t o_in, const void *buf, mp_uint_t siz eagain: r = ssl_write(o->ssl_sock, buf, size); if (r == 0) { - // see comment in ussl_socket_read above + // see comment in ssl_socket_read above if (o->blocking) { goto eagain; } else { @@ -271,7 +271,7 @@ STATIC mp_uint_t ussl_socket_write(mp_obj_t o_in, const void *buf, mp_uint_t siz return r; } -STATIC mp_uint_t ussl_socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) { +STATIC mp_uint_t ssl_socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) { mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(o_in); if (request == MP_STREAM_CLOSE && self->ssl_sock != NULL) { ssl_free(self->ssl_sock); @@ -282,7 +282,7 @@ STATIC mp_uint_t ussl_socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t a return mp_get_stream(self->sock)->ioctl(self->sock, request, arg, errcode); } -STATIC mp_obj_t ussl_socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) { +STATIC mp_obj_t ssl_socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) { mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(self_in); mp_obj_t sock = o->sock; mp_obj_t dest[3]; @@ -292,36 +292,36 @@ STATIC mp_obj_t ussl_socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) { o->blocking = mp_obj_is_true(flag_in); return res; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(ussl_socket_setblocking_obj, ussl_socket_setblocking); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_socket_setblocking_obj, ssl_socket_setblocking); -STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = { +STATIC const mp_rom_map_elem_t ssl_socket_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&ussl_socket_setblocking_obj) }, + { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&ssl_socket_setblocking_obj) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) }, #if MICROPY_PY_USSL_FINALISER { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_stream_close_obj) }, #endif }; -STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(ssl_socket_locals_dict, ssl_socket_locals_dict_table); -STATIC const mp_stream_p_t ussl_socket_stream_p = { - .read = ussl_socket_read, - .write = ussl_socket_write, - .ioctl = ussl_socket_ioctl, +STATIC const mp_stream_p_t ssl_socket_stream_p = { + .read = ssl_socket_read, + .write = ssl_socket_write, + .ioctl = ssl_socket_ioctl, }; STATIC MP_DEFINE_CONST_OBJ_TYPE( - ussl_socket_type, + ssl_socket_type, // Save on qstr's, reuse same as for module MP_QSTR_ssl, MP_TYPE_FLAG_NONE, - print, ussl_socket_print, - protocol, &ussl_socket_stream_p, - locals_dict, &ussl_socket_locals_dict + print, ssl_socket_print, + protocol, &ssl_socket_stream_p, + locals_dict, &ssl_socket_locals_dict ); STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -341,7 +341,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t *)&args); - return MP_OBJ_FROM_PTR(ussl_socket_new(sock, &args)); + return MP_OBJ_FROM_PTR(ssl_socket_new(sock, &args)); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket); diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c index 117a06b6b28..dbe802f75b1 100644 --- a/extmod/modussl_mbedtls.c +++ b/extmod/modussl_mbedtls.c @@ -73,7 +73,7 @@ struct ssl_args { mp_arg_val_t do_handshake; }; -STATIC const mp_obj_type_t ussl_socket_type; +STATIC const mp_obj_type_t ssl_socket_type; #ifdef MBEDTLS_DEBUG_C STATIC void mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str) { @@ -168,7 +168,7 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) { #else mp_obj_ssl_socket_t *o = m_new_obj(mp_obj_ssl_socket_t); #endif - o->base.type = &ussl_socket_type; + o->base.type = &ssl_socket_type; o->sock = sock; o->poll_mask = 0; o->last_error = 0; @@ -435,7 +435,7 @@ STATIC mp_uint_t socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, i return ret; } -STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = { +STATIC const mp_rom_map_elem_t ssl_socket_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) }, { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) }, @@ -451,22 +451,22 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_getpeercert), MP_ROM_PTR(&mod_ssl_getpeercert_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(ssl_socket_locals_dict, ssl_socket_locals_dict_table); -STATIC const mp_stream_p_t ussl_socket_stream_p = { +STATIC const mp_stream_p_t ssl_socket_stream_p = { .read = socket_read, .write = socket_write, .ioctl = socket_ioctl, }; STATIC MP_DEFINE_CONST_OBJ_TYPE( - ussl_socket_type, + ssl_socket_type, // Save on qstr's, reuse same as for module MP_QSTR_ssl, MP_TYPE_FLAG_NONE, print, socket_print, - protocol, &ussl_socket_stream_p, - locals_dict, &ussl_socket_locals_dict + protocol, &ssl_socket_stream_p, + locals_dict, &ssl_socket_locals_dict ); STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c index 8187fa2b23c..643aef5d6d3 100644 --- a/extmod/modutimeq.c +++ b/extmod/modutimeq.c @@ -46,16 +46,16 @@ struct qentry { mp_obj_t args; }; -typedef struct _mp_obj_utimeq_t { +typedef struct _mp_obj_timeq_t { mp_obj_base_t base; mp_uint_t alloc; mp_uint_t len; struct qentry items[]; -} mp_obj_utimeq_t; +} mp_obj_timeq_t; -STATIC mp_uint_t utimeq_id; +STATIC mp_uint_t timeq_id; -STATIC mp_obj_utimeq_t *utimeq_get_heap(mp_obj_t heap_in) { +STATIC mp_obj_timeq_t *timeq_get_heap(mp_obj_t heap_in) { return MP_OBJ_TO_PTR(heap_in); } @@ -74,17 +74,17 @@ STATIC bool time_less_than(struct qentry *item, struct qentry *parent) { return res && res < (MODULO / 2); } -STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t timeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_uint_t alloc = mp_obj_get_int(args[0]); - mp_obj_utimeq_t *o = mp_obj_malloc_var(mp_obj_utimeq_t, struct qentry, alloc, type); + mp_obj_timeq_t *o = mp_obj_malloc_var(mp_obj_timeq_t, struct qentry, alloc, type); memset(o->items, 0, sizeof(*o->items) * alloc); o->alloc = alloc; o->len = 0; return MP_OBJ_FROM_PTR(o); } -STATIC void utimeq_heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) { +STATIC void timeq_heap_siftdown(mp_obj_timeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) { struct qentry item = heap->items[pos]; while (pos > start_pos) { mp_uint_t parent_pos = (pos - 1) >> 1; @@ -100,7 +100,7 @@ STATIC void utimeq_heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_ heap->items[pos] = item; } -STATIC void utimeq_heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) { +STATIC void timeq_heap_siftup(mp_obj_timeq_t *heap, mp_uint_t pos) { mp_uint_t start_pos = pos; mp_uint_t end_pos = heap->len; struct qentry item = heap->items[pos]; @@ -117,29 +117,29 @@ STATIC void utimeq_heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) { pos = child_pos; } heap->items[pos] = item; - utimeq_heap_siftdown(heap, start_pos, pos); + timeq_heap_siftdown(heap, start_pos, pos); } -STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t mod_timeq_heappush(size_t n_args, const mp_obj_t *args) { (void)n_args; mp_obj_t heap_in = args[0]; - mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in); + mp_obj_timeq_t *heap = timeq_get_heap(heap_in); if (heap->len == heap->alloc) { mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("queue overflow")); } mp_uint_t l = heap->len; heap->items[l].time = MP_OBJ_SMALL_INT_VALUE(args[1]); - heap->items[l].id = utimeq_id++; + heap->items[l].id = timeq_id++; heap->items[l].callback = args[2]; heap->items[l].args = args[3]; - utimeq_heap_siftdown(heap, 0, heap->len); + timeq_heap_siftdown(heap, 0, heap->len); heap->len++; return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_utimeq_heappush_obj, 4, 4, mod_utimeq_heappush); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_timeq_heappush_obj, 4, 4, mod_timeq_heappush); -STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) { - mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in); +STATIC mp_obj_t mod_timeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) { + mp_obj_timeq_t *heap = timeq_get_heap(heap_in); if (heap->len == 0) { mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("empty heap")); } @@ -157,14 +157,14 @@ STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) { heap->items[heap->len].callback = MP_OBJ_NULL; // so we don't retain a pointer heap->items[heap->len].args = MP_OBJ_NULL; if (heap->len) { - utimeq_heap_siftup(heap, 0); + timeq_heap_siftup(heap, 0); } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_utimeq_heappop_obj, mod_utimeq_heappop); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_timeq_heappop_obj, mod_timeq_heappop); -STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) { - mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in); +STATIC mp_obj_t mod_timeq_peektime(mp_obj_t heap_in) { + mp_obj_timeq_t *heap = timeq_get_heap(heap_in); if (heap->len == 0) { mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("empty heap")); } @@ -172,22 +172,22 @@ STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) { struct qentry *item = &heap->items[0]; return MP_OBJ_NEW_SMALL_INT(item->time); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_peektime_obj, mod_utimeq_peektime); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_timeq_peektime_obj, mod_timeq_peektime); #if DEBUG -STATIC mp_obj_t mod_utimeq_dump(mp_obj_t heap_in) { - mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in); +STATIC mp_obj_t mod_timeq_dump(mp_obj_t heap_in) { + mp_obj_timeq_t *heap = timeq_get_heap(heap_in); for (int i = 0; i < heap->len; i++) { printf(UINT_FMT "\t%p\t%p\n", heap->items[i].time, MP_OBJ_TO_PTR(heap->items[i].callback), MP_OBJ_TO_PTR(heap->items[i].args)); } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_dump_obj, mod_utimeq_dump); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_timeq_dump_obj, mod_timeq_dump); #endif -STATIC mp_obj_t utimeq_unary_op(mp_unary_op_t op, mp_obj_t self_in) { - mp_obj_utimeq_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t timeq_unary_op(mp_unary_op_t op, mp_obj_t self_in) { + mp_obj_timeq_t *self = MP_OBJ_TO_PTR(self_in); switch (op) { case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); @@ -198,29 +198,29 @@ STATIC mp_obj_t utimeq_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } -STATIC const mp_rom_map_elem_t utimeq_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_push), MP_ROM_PTR(&mod_utimeq_heappush_obj) }, - { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&mod_utimeq_heappop_obj) }, - { MP_ROM_QSTR(MP_QSTR_peektime), MP_ROM_PTR(&mod_utimeq_peektime_obj) }, +STATIC const mp_rom_map_elem_t timeq_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_push), MP_ROM_PTR(&mod_timeq_heappush_obj) }, + { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&mod_timeq_heappop_obj) }, + { MP_ROM_QSTR(MP_QSTR_peektime), MP_ROM_PTR(&mod_timeq_peektime_obj) }, #if DEBUG - { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_utimeq_dump_obj) }, + { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_timeq_dump_obj) }, #endif }; -STATIC MP_DEFINE_CONST_DICT(utimeq_locals_dict, utimeq_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(timeq_locals_dict, timeq_locals_dict_table); STATIC MP_DEFINE_CONST_OBJ_TYPE( - utimeq_type, + timeq_type, MP_QSTR_timeq, MP_TYPE_FLAG_NONE, - make_new, utimeq_make_new, - unary_op, utimeq_unary_op, - locals_dict, &utimeq_locals_dict + make_new, timeq_make_new, + unary_op, timeq_unary_op, + locals_dict, &timeq_locals_dict ); STATIC const mp_rom_map_elem_t mp_module_timeq_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_timeq) }, - { MP_ROM_QSTR(MP_QSTR_timeq), MP_ROM_PTR(&utimeq_type) }, + { MP_ROM_QSTR(MP_QSTR_timeq), MP_ROM_PTR(&timeq_type) }, }; STATIC MP_DEFINE_CONST_DICT(mp_module_timeq_globals, mp_module_timeq_globals_table); diff --git a/extmod/moduwebsocket.c b/extmod/moduwebsocket.c index 301f72fba04..76330f31259 100644 --- a/extmod/moduwebsocket.c +++ b/extmod/moduwebsocket.c @@ -299,16 +299,16 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( locals_dict, &websocket_locals_dict ); -STATIC const mp_rom_map_elem_t uwebsocket_module_globals_table[] = { +STATIC const mp_rom_map_elem_t websocket_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_websocket) }, { MP_ROM_QSTR(MP_QSTR_websocket), MP_ROM_PTR(&websocket_type) }, }; -STATIC MP_DEFINE_CONST_DICT(uwebsocket_module_globals, uwebsocket_module_globals_table); +STATIC MP_DEFINE_CONST_DICT(websocket_module_globals, websocket_module_globals_table); const mp_obj_module_t mp_module_websocket = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&uwebsocket_module_globals, + .globals = (mp_obj_dict_t *)&websocket_module_globals, }; MP_REGISTER_MODULE(MP_QSTR_websocket, mp_module_websocket); diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index 504c637c3c7..e840bdcbfd5 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -150,7 +150,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); #endif -STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t mod_zlib_decompress(size_t n_args, const mp_obj_t *args) { mp_obj_t data = args[0]; mp_buffer_info_t bufinfo; mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); @@ -164,7 +164,7 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { decomp->dest = dest_buf; decomp->dest_limit = dest_buf + dest_buf_size; - DEBUG_printf("uzlib: Initial out buffer: " UINT_FMT " bytes\n", dest_buf_size); + DEBUG_printf("zlib: Initial out buffer: " UINT_FMT " bytes\n", dest_buf_size); decomp->source = bufinfo.buf; decomp->source_limit = (byte *)bufinfo.buf + bufinfo.len; @@ -198,7 +198,7 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { } mp_uint_t final_sz = decomp->dest - dest_buf; - DEBUG_printf("uzlib: Resizing from " UINT_FMT " to final size: " UINT_FMT " bytes\n", dest_buf_size, final_sz); + DEBUG_printf("zlib: Resizing from " UINT_FMT " to final size: " UINT_FMT " bytes\n", dest_buf_size, final_sz); dest_buf = (byte *)m_renew(byte, dest_buf, dest_buf_size, final_sz); mp_obj_t res = mp_obj_new_bytearray_by_ref(final_sz, dest_buf); m_del_obj(TINF_DATA, decomp); @@ -207,12 +207,12 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { error: mp_raise_type_arg(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st)); } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_zlib_decompress_obj, 1, 3, mod_zlib_decompress); #if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_rom_map_elem_t mp_module_zlib_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_zlib) }, - { MP_ROM_QSTR(MP_QSTR_decompress), MP_ROM_PTR(&mod_uzlib_decompress_obj) }, + { MP_ROM_QSTR(MP_QSTR_decompress), MP_ROM_PTR(&mod_zlib_decompress_obj) }, { MP_ROM_QSTR(MP_QSTR_DecompIO), MP_ROM_PTR(&decompio_type) }, }; diff --git a/ports/cc3200/mods/modusocket.c b/ports/cc3200/mods/modusocket.c index 53682743a9c..da756296fc9 100644 --- a/ports/cc3200/mods/modusocket.c +++ b/ports/cc3200/mods/modusocket.c @@ -41,14 +41,14 @@ /******************************************************************************/ // The following set of macros and functions provide a glue between the CC3100 -// simplelink layer and the functions/methods provided by the usocket module. -// They were historically in a separate file because usocket was designed to +// simplelink layer and the functions/methods provided by the socket module. +// They were historically in a separate file because socket was designed to // work with multiple NICs, and the wlan_XXX functions just provided one // particular NIC implementation (that of the CC3100). But the CC3200 port only // supports a single NIC (being the CC3100) so it's unnecessary and inefficient // to provide an intermediate wrapper layer. Hence the wlan_XXX functions // are provided below as static functions so they can be inlined directly by -// the corresponding usocket calls. +// the corresponding socket calls. #define WLAN_MAX_RX_SIZE 16000 #define WLAN_MAX_TX_SIZE 1476 @@ -769,11 +769,11 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); /******************************************************************************/ -// usocket module +// socket module -// function usocket.getaddrinfo(host, port) +// function socket.getaddrinfo(host, port) /// \function getaddrinfo(host, port) -STATIC mp_obj_t mod_usocket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) { +STATIC mp_obj_t mod_socket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) { size_t hlen; const char *host = mp_obj_str_get_data(host_in, &hlen); mp_int_t port = mp_obj_get_int(port_in); @@ -792,13 +792,13 @@ STATIC mp_obj_t mod_usocket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) { tuple->items[4] = netutils_format_inet_addr(out_ip, port, NETUTILS_LITTLE); return mp_obj_new_list(1, (mp_obj_t*)&tuple); } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_usocket_getaddrinfo_obj, mod_usocket_getaddrinfo); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_socket_getaddrinfo_obj, mod_socket_getaddrinfo); STATIC const mp_rom_map_elem_t mp_module_socket_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_socket) }, { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socket_type) }, - { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&mod_usocket_getaddrinfo_obj) }, + { MP_ROM_QSTR(MP_QSTR_getaddrinfo), MP_ROM_PTR(&mod_socket_getaddrinfo_obj) }, // class constants { MP_ROM_QSTR(MP_QSTR_AF_INET), MP_ROM_INT(SL_AF_INET) }, diff --git a/ports/cc3200/mpconfigport.h b/ports/cc3200/mpconfigport.h index aa78005d68b..8026f7b7575 100644 --- a/ports/cc3200/mpconfigport.h +++ b/ports/cc3200/mpconfigport.h @@ -125,7 +125,7 @@ #define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) #define MICROPY_KBD_EXCEPTION (1) -// We define our own list of errno constants to include in uerrno module +// We define our own list of errno constants to include in errno module #define MICROPY_PY_UERRNO_LIST \ X(EPERM) \ X(EIO) \ diff --git a/ports/esp32/main.c b/ports/esp32/main.c index 0d876eb5f72..b3d467a80e9 100644 --- a/ports/esp32/main.c +++ b/ports/esp32/main.c @@ -225,7 +225,7 @@ void mp_task(void *pvParameter) { machine_pins_deinit(); machine_deinit(); #if MICROPY_PY_USOCKET_EVENTS - usocket_events_deinit(); + socket_events_deinit(); #endif mp_deinit(); diff --git a/ports/esp32/modnetwork.h b/ports/esp32/modnetwork.h index 80537ea473a..ac6321d8f6f 100644 --- a/ports/esp32/modnetwork.h +++ b/ports/esp32/modnetwork.h @@ -63,7 +63,7 @@ static inline void esp_exceptions(esp_err_t e) { } } -void usocket_events_deinit(void); +void socket_events_deinit(void); void network_wlan_event_handler(system_event_t *event); void esp_initialise_wifi(void); diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index 81993044575..114629a9d77 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -87,22 +87,22 @@ void _socket_settimeout(socket_obj_t *sock, uint64_t timeout_ms); // This divisor is used to reduce the load on the system, so it doesn't poll sockets too often #define USOCKET_EVENTS_DIVISOR (8) -STATIC uint8_t usocket_events_divisor; -STATIC socket_obj_t *usocket_events_head; +STATIC uint8_t socket_events_divisor; +STATIC socket_obj_t *socket_events_head; -void usocket_events_deinit(void) { - usocket_events_head = NULL; +void socket_events_deinit(void) { + socket_events_head = NULL; } // Assumes the socket is not already in the linked list, and adds it -STATIC void usocket_events_add(socket_obj_t *sock) { - sock->events_next = usocket_events_head; - usocket_events_head = sock; +STATIC void socket_events_add(socket_obj_t *sock) { + sock->events_next = socket_events_head; + socket_events_head = sock; } // Assumes the socket is already in the linked list, and removes it -STATIC void usocket_events_remove(socket_obj_t *sock) { - for (socket_obj_t **s = &usocket_events_head;; s = &(*s)->events_next) { +STATIC void socket_events_remove(socket_obj_t *sock) { + for (socket_obj_t **s = &socket_events_head;; s = &(*s)->events_next) { if (*s == sock) { *s = (*s)->events_next; return; @@ -111,20 +111,20 @@ STATIC void usocket_events_remove(socket_obj_t *sock) { } // Polls all registered sockets for readability and calls their callback if they are readable -void usocket_events_handler(void) { - if (usocket_events_head == NULL) { +void socket_events_handler(void) { + if (socket_events_head == NULL) { return; } - if (--usocket_events_divisor) { + if (--socket_events_divisor) { return; } - usocket_events_divisor = USOCKET_EVENTS_DIVISOR; + socket_events_divisor = USOCKET_EVENTS_DIVISOR; fd_set rfds; FD_ZERO(&rfds); int max_fd = 0; - for (socket_obj_t *s = usocket_events_head; s != NULL; s = s->events_next) { + for (socket_obj_t *s = socket_events_head; s != NULL; s = s->events_next) { FD_SET(s->fd, &rfds); max_fd = MAX(max_fd, s->fd); } @@ -137,7 +137,7 @@ void usocket_events_handler(void) { } // Call the callbacks - for (socket_obj_t *s = usocket_events_head; s != NULL; s = s->events_next) { + for (socket_obj_t *s = socket_events_head; s != NULL; s = s->events_next) { if (FD_ISSET(s->fd, &rfds)) { mp_call_function_1_protected(s->events_callback, s); } @@ -402,12 +402,12 @@ STATIC mp_obj_t socket_setsockopt(size_t n_args, const mp_obj_t *args) { case 20: { if (args[3] == mp_const_none) { if (self->events_callback != MP_OBJ_NULL) { - usocket_events_remove(self); + socket_events_remove(self); self->events_callback = MP_OBJ_NULL; } } else { if (self->events_callback == MP_OBJ_NULL) { - usocket_events_add(self); + socket_events_add(self); } self->events_callback = args[3]; } @@ -736,7 +736,7 @@ STATIC mp_uint_t socket_stream_ioctl(mp_obj_t self_in, mp_uint_t request, uintpt if (socket->fd >= 0) { #if MICROPY_PY_USOCKET_EVENTS if (socket->events_callback != MP_OBJ_NULL) { - usocket_events_remove(socket); + socket_events_remove(socket); socket->events_callback = MP_OBJ_NULL; } #endif @@ -871,5 +871,5 @@ const mp_obj_module_t mp_module_socket = { // Note: This port doesn't define MICROPY_PY_USOCKET or MICROPY_PY_LWIP so // this will not conflict with the common implementation provided by -// extmod/mod{lwip,usocket}.c. +// extmod/mod{lwip,socket}.c. MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index 4701040e666..d6aaa987872 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -170,7 +170,7 @@ void *esp_native_code_commit(void *, size_t, void *); #define MICROPY_END_ATOMIC_SECTION(state) portEXIT_CRITICAL_NESTED(state) #if MICROPY_PY_USOCKET_EVENTS -#define MICROPY_PY_USOCKET_EVENTS_HANDLER extern void usocket_events_handler(void); usocket_events_handler(); +#define MICROPY_PY_USOCKET_EVENTS_HANDLER extern void socket_events_handler(void); socket_events_handler(); #else #define MICROPY_PY_USOCKET_EVENTS_HANDLER #endif diff --git a/ports/nrf/main.c b/ports/nrf/main.c index f64107f8907..7f35c7f1b34 100644 --- a/ports/nrf/main.c +++ b/ports/nrf/main.c @@ -43,7 +43,7 @@ #include "gccollect.h" #include "modmachine.h" #include "modmusic.h" -#include "modules/uos/microbitfs.h" +#include "modules/os/microbitfs.h" #include "led.h" #include "uart.h" #include "nrf.h" @@ -301,15 +301,15 @@ int main(int argc, char **argv) { #if MICROPY_MBFS // Use micro:bit filesystem mp_lexer_t *mp_lexer_new_from_file(const char *filename) { - return uos_mbfs_new_reader(filename); + return os_mbfs_new_reader(filename); } mp_import_stat_t mp_import_stat(const char *path) { - return uos_mbfs_import_stat(path); + return os_mbfs_import_stat(path); } mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { - return uos_mbfs_open(n_args, args); + return os_mbfs_open(n_args, args); } MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open); diff --git a/ports/nrf/modules/uos/microbitfs.c b/ports/nrf/modules/uos/microbitfs.c index f4c2d20a091..5ffe837efea 100644 --- a/ports/nrf/modules/uos/microbitfs.c +++ b/ports/nrf/modules/uos/microbitfs.c @@ -121,8 +121,8 @@ typedef struct _persistent_config_t { uint8_t marker; // Should always be PERSISTENT_DATA_MARKER } persistent_config_t; -extern const mp_obj_type_t uos_mbfs_fileio_type; -extern const mp_obj_type_t uos_mbfs_textio_type; +extern const mp_obj_type_t os_mbfs_fileio_type; +extern const mp_obj_type_t os_mbfs_textio_type; // Page indexes count down from the end of ROM. STATIC uint8_t first_page_index; @@ -360,7 +360,7 @@ STATIC file_descriptor_obj *microbit_file_open(const char *name, size_t name_len } STATIC file_descriptor_obj *microbit_file_descriptor_new(uint8_t start_chunk, bool write, bool binary) { - file_descriptor_obj *res = mp_obj_malloc(file_descriptor_obj, binary ? &uos_mbfs_fileio_type : &uos_mbfs_textio_type); + file_descriptor_obj *res = mp_obj_malloc(file_descriptor_obj, binary ? &os_mbfs_fileio_type : &os_mbfs_textio_type); res->start_chunk = start_chunk; res->seek_chunk = start_chunk; res->seek_offset = file_system_chunks[start_chunk].header.name_len+2; @@ -511,9 +511,9 @@ STATIC mp_uint_t file_read_byte(file_descriptor_obj *fd) { return res; } -// Now follows the code to integrate this filesystem into the uos module. +// Now follows the code to integrate this filesystem into the os module. -mp_lexer_t *uos_mbfs_new_reader(const char *filename) { +mp_lexer_t *os_mbfs_new_reader(const char *filename) { file_descriptor_obj *fd = microbit_file_open(filename, strlen(filename), false, false); if (fd == NULL) { mp_raise_OSError(MP_ENOENT); @@ -525,7 +525,7 @@ mp_lexer_t *uos_mbfs_new_reader(const char *filename) { return mp_lexer_new(qstr_from_str(filename), reader); } -mp_import_stat_t uos_mbfs_import_stat(const char *path) { +mp_import_stat_t os_mbfs_import_stat(const char *path) { uint8_t chunk = microbit_find_file(path, strlen(path)); if (chunk == FILE_NOT_FOUND) { return MP_IMPORT_STAT_NO_EXIST; @@ -534,38 +534,38 @@ mp_import_stat_t uos_mbfs_import_stat(const char *path) { } } -STATIC mp_obj_t uos_mbfs_file_name(mp_obj_t self) { +STATIC mp_obj_t os_mbfs_file_name(mp_obj_t self) { file_descriptor_obj *fd = (file_descriptor_obj*)self; return microbit_file_name(fd); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(uos_mbfs_file_name_obj, uos_mbfs_file_name); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_mbfs_file_name_obj, os_mbfs_file_name); -STATIC mp_obj_t uos_mbfs_file_close(mp_obj_t self) { +STATIC mp_obj_t os_mbfs_file_close(mp_obj_t self) { file_descriptor_obj *fd = (file_descriptor_obj*)self; microbit_file_close(fd); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(uos_mbfs_file_close_obj, uos_mbfs_file_close); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_mbfs_file_close_obj, os_mbfs_file_close); -STATIC mp_obj_t uos_mbfs_remove(mp_obj_t name) { +STATIC mp_obj_t os_mbfs_remove(mp_obj_t name) { return microbit_remove(name); } -MP_DEFINE_CONST_FUN_OBJ_1(uos_mbfs_remove_obj, uos_mbfs_remove); +MP_DEFINE_CONST_FUN_OBJ_1(os_mbfs_remove_obj, os_mbfs_remove); -STATIC mp_obj_t uos_mbfs_file___exit__(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t os_mbfs_file___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; - return uos_mbfs_file_close(args[0]); + return os_mbfs_file_close(args[0]); } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(uos_mbfs_file___exit___obj, 4, 4, uos_mbfs_file___exit__); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(os_mbfs_file___exit___obj, 4, 4, os_mbfs_file___exit__); typedef struct { mp_obj_base_t base; mp_fun_1_t iternext; uint8_t index; -} uos_mbfs_ilistdir_it_t; +} os_mbfs_ilistdir_it_t; -STATIC mp_obj_t uos_mbfs_ilistdir_it_iternext(mp_obj_t self_in) { - uos_mbfs_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t os_mbfs_ilistdir_it_iternext(mp_obj_t self_in) { + os_mbfs_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in); // Read until the next FILE_START chunk. for (; self->index <= chunks_in_file_system; self->index++) { @@ -589,27 +589,27 @@ STATIC mp_obj_t uos_mbfs_ilistdir_it_iternext(mp_obj_t self_in) { return MP_OBJ_STOP_ITERATION; } -STATIC mp_obj_t uos_mbfs_ilistdir(void) { - uos_mbfs_ilistdir_it_t *iter = mp_obj_malloc(uos_mbfs_ilistdir_it_t, &mp_type_polymorph_iter); - iter->iternext = uos_mbfs_ilistdir_it_iternext; +STATIC mp_obj_t os_mbfs_ilistdir(void) { + os_mbfs_ilistdir_it_t *iter = mp_obj_malloc(os_mbfs_ilistdir_it_t, &mp_type_polymorph_iter); + iter->iternext = os_mbfs_ilistdir_it_iternext; iter->index = 1; return MP_OBJ_FROM_PTR(iter); } -MP_DEFINE_CONST_FUN_OBJ_0(uos_mbfs_ilistdir_obj, uos_mbfs_ilistdir); +MP_DEFINE_CONST_FUN_OBJ_0(os_mbfs_ilistdir_obj, os_mbfs_ilistdir); -MP_DEFINE_CONST_FUN_OBJ_0(uos_mbfs_listdir_obj, microbit_file_list); +MP_DEFINE_CONST_FUN_OBJ_0(os_mbfs_listdir_obj, microbit_file_list); STATIC mp_obj_t microbit_file_writable(mp_obj_t self) { return mp_obj_new_bool(((file_descriptor_obj *)self)->writable); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(microbit_file_writable_obj, microbit_file_writable); -STATIC const mp_map_elem_t uos_mbfs_file_locals_dict_table[] = { - { MP_OBJ_NEW_QSTR(MP_QSTR_close), (mp_obj_t)&uos_mbfs_file_close_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_name), (mp_obj_t)&uos_mbfs_file_name_obj }, +STATIC const mp_map_elem_t os_mbfs_file_locals_dict_table[] = { + { MP_OBJ_NEW_QSTR(MP_QSTR_close), (mp_obj_t)&os_mbfs_file_close_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_name), (mp_obj_t)&os_mbfs_file_name_obj }, { MP_ROM_QSTR(MP_QSTR___enter__), (mp_obj_t)&mp_identity_obj }, - { MP_ROM_QSTR(MP_QSTR___exit__), (mp_obj_t)&uos_mbfs_file___exit___obj }, + { MP_ROM_QSTR(MP_QSTR___exit__), (mp_obj_t)&os_mbfs_file___exit___obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_writable), (mp_obj_t)µbit_file_writable_obj }, /* Stream methods */ { MP_OBJ_NEW_QSTR(MP_QSTR_read), (mp_obj_t)&mp_stream_read_obj }, @@ -617,7 +617,7 @@ STATIC const mp_map_elem_t uos_mbfs_file_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_readline), (mp_obj_t)&mp_stream_unbuffered_readline_obj}, { MP_OBJ_NEW_QSTR(MP_QSTR_write), (mp_obj_t)&mp_stream_write_obj}, }; -STATIC MP_DEFINE_CONST_DICT(uos_mbfs_file_locals_dict, uos_mbfs_file_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(os_mbfs_file_locals_dict, os_mbfs_file_locals_dict_table); STATIC const mp_stream_p_t textio_stream_p = { @@ -627,11 +627,11 @@ STATIC const mp_stream_p_t textio_stream_p = { }; MP_DEFINE_CONST_OBJ_TYPE( - uos_mbfs_textio_type, + os_mbfs_textio_type, MP_QSTR_TextIO, MP_TYPE_FLAG_NONE, protocol, &textio_stream_p, - locals_dict, &uos_mbfs_file_locals_dict + locals_dict, &os_mbfs_file_locals_dict ); @@ -641,15 +641,15 @@ STATIC const mp_stream_p_t fileio_stream_p = { }; MP_DEFINE_CONST_OBJ_TYPE( - uos_mbfs_fileio_type, + os_mbfs_fileio_type, MP_QSTR_FileIO, MP_TYPE_FLAG_NONE, protocol, &fileio_stream_p, - locals_dict, &uos_mbfs_file_locals_dict + locals_dict, &os_mbfs_file_locals_dict ); // From micro:bit fileobj.c -mp_obj_t uos_mbfs_open(size_t n_args, const mp_obj_t *args) { +mp_obj_t os_mbfs_open(size_t n_args, const mp_obj_t *args) { /// -1 means default; 0 explicitly false; 1 explicitly true. int read = -1; int text = -1; @@ -683,7 +683,7 @@ mp_obj_t uos_mbfs_open(size_t n_args, const mp_obj_t *args) { mp_raise_ValueError(MP_ERROR_TEXT("illegal mode")); } -STATIC mp_obj_t uos_mbfs_stat(mp_obj_t filename) { +STATIC mp_obj_t os_mbfs_stat(mp_obj_t filename) { mp_obj_t file_size = microbit_file_size(filename); mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); @@ -699,6 +699,6 @@ STATIC mp_obj_t uos_mbfs_stat(mp_obj_t filename) { t->items[9] = MP_OBJ_NEW_SMALL_INT(0); // st_ctime return MP_OBJ_FROM_PTR(t); } -MP_DEFINE_CONST_FUN_OBJ_1(uos_mbfs_stat_obj, uos_mbfs_stat); +MP_DEFINE_CONST_FUN_OBJ_1(os_mbfs_stat_obj, os_mbfs_stat); #endif // MICROPY_MBFS diff --git a/ports/nrf/modules/uos/microbitfs.h b/ports/nrf/modules/uos/microbitfs.h index 645a1e32896..56d111383e2 100644 --- a/ports/nrf/modules/uos/microbitfs.h +++ b/ports/nrf/modules/uos/microbitfs.h @@ -40,14 +40,14 @@ #define MBFS_LOG_CHUNK_SIZE 7 #endif -mp_obj_t uos_mbfs_open(size_t n_args, const mp_obj_t *args); +mp_obj_t os_mbfs_open(size_t n_args, const mp_obj_t *args); void microbit_filesystem_init(void); -mp_lexer_t *uos_mbfs_new_reader(const char *filename); -mp_import_stat_t uos_mbfs_import_stat(const char *path); +mp_lexer_t *os_mbfs_new_reader(const char *filename); +mp_import_stat_t os_mbfs_import_stat(const char *path); -MP_DECLARE_CONST_FUN_OBJ_0(uos_mbfs_listdir_obj); -MP_DECLARE_CONST_FUN_OBJ_0(uos_mbfs_ilistdir_obj); -MP_DECLARE_CONST_FUN_OBJ_1(uos_mbfs_remove_obj); -MP_DECLARE_CONST_FUN_OBJ_1(uos_mbfs_stat_obj); +MP_DECLARE_CONST_FUN_OBJ_0(os_mbfs_listdir_obj); +MP_DECLARE_CONST_FUN_OBJ_0(os_mbfs_ilistdir_obj); +MP_DECLARE_CONST_FUN_OBJ_1(os_mbfs_remove_obj); +MP_DECLARE_CONST_FUN_OBJ_1(os_mbfs_stat_obj); #endif // __MICROPY_INCLUDED_FILESYSTEM_H__ diff --git a/ports/nrf/modules/uos/moduos.c b/ports/nrf/modules/uos/moduos.c index b7181506134..7c54f28ab45 100644 --- a/ports/nrf/modules/uos/moduos.c +++ b/ports/nrf/modules/uos/moduos.c @@ -33,7 +33,7 @@ #include "py/objstr.h" #include "lib/oofatfs/ff.h" #include "lib/oofatfs/diskio.h" -#include "modules/uos/microbitfs.h" +#include "modules/os/microbitfs.h" #include "extmod/vfs.h" #include "extmod/vfs_fat.h" #include "extmod/vfs_lfs.h" @@ -158,10 +158,10 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&mod_os_sync_obj) }, #elif MICROPY_MBFS - { MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&uos_mbfs_listdir_obj) }, - { MP_ROM_QSTR(MP_QSTR_ilistdir), MP_ROM_PTR(&uos_mbfs_ilistdir_obj) }, // uses ~136 bytes - { MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&uos_mbfs_stat_obj) }, // uses ~228 bytes - { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&uos_mbfs_remove_obj) }, + { MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&os_mbfs_listdir_obj) }, + { MP_ROM_QSTR(MP_QSTR_ilistdir), MP_ROM_PTR(&os_mbfs_ilistdir_obj) }, // uses ~136 bytes + { MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&os_mbfs_stat_obj) }, // uses ~228 bytes + { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&os_mbfs_remove_obj) }, #endif /// \constant sep - separation character used in paths diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 3d482f4fe1f..0799000b908 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -133,7 +133,7 @@ #define MICROPY_FATFS_MAX_SS (4096) #endif -// Use port specific uos module rather than extmod variant. +// Use port specific os module rather than extmod variant. #define MICROPY_PY_UOS (0) #define MICROPY_STREAMS_NON_BLOCK (1) diff --git a/ports/nrf/qstrdefsport.h b/ports/nrf/qstrdefsport.h index 3cc2f1e6468..f12cf40efad 100644 --- a/ports/nrf/qstrdefsport.h +++ b/ports/nrf/qstrdefsport.h @@ -30,7 +30,7 @@ // Entries for sys.path Q(/flash) -// For uos.sep +// For os.sep Q(/) Q(a) diff --git a/ports/renesas-ra/qstrdefsport.h b/ports/renesas-ra/qstrdefsport.h index bc07f2752aa..7f5743bbdce 100644 --- a/ports/renesas-ra/qstrdefsport.h +++ b/ports/renesas-ra/qstrdefsport.h @@ -33,7 +33,7 @@ Q(/flash/lib) Q(/sd) Q(/sd/lib) -// For uos.sep +// For os.sep Q(/) #if MICROPY_HW_ENABLE_USB diff --git a/ports/samd/modmachine.c b/ports/samd/modmachine.c index 7e231b28b45..9890e3b590f 100644 --- a/ports/samd/modmachine.c +++ b/ports/samd/modmachine.c @@ -116,7 +116,7 @@ STATIC mp_obj_t machine_unique_id(void) { // 0x0080a040: 50534b54 332e3120 ff091645 // // MicroPython (this code and same order as shown in Arduino IDE) - // >>> ubinascii.hexlify(machine.unique_id()) + // >>> binascii.hexlify(machine.unique_id()) // b'6e27f15f50534b54332e3120ff091645' #if defined(MCU_SAMD21) diff --git a/ports/stm32/modpyb.c b/ports/stm32/modpyb.c index 88eafafb0aa..b7d6fe7e6a1 100644 --- a/ports/stm32/modpyb.c +++ b/ports/stm32/modpyb.c @@ -89,7 +89,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_micros_obj, pyb_elapsed_micros); MP_DECLARE_CONST_FUN_OBJ_KW(pyb_main_obj); // defined in main.c // Get or set the UART object that the REPL is repeated on. -// This is a legacy function, use of uos.dupterm is preferred. +// This is a legacy function, use of os.dupterm is preferred. STATIC mp_obj_t pyb_repl_uart(size_t n_args, const mp_obj_t *args) { if (n_args == 0) { if (MP_STATE_PORT(pyb_stdio_uart) == NULL) { diff --git a/ports/stm32/qstrdefsport.h b/ports/stm32/qstrdefsport.h index e7d84cbec0e..d44388ebd2e 100644 --- a/ports/stm32/qstrdefsport.h +++ b/ports/stm32/qstrdefsport.h @@ -33,7 +33,7 @@ Q(/flash/lib) Q(/sd) Q(/sd/lib) -// For uos.sep +// For os.sep Q(/) #if MICROPY_HW_ENABLE_USB diff --git a/ports/stm32/rng.c b/ports/stm32/rng.c index eea02f72657..5d6ddf6d62c 100644 --- a/ports/stm32/rng.c +++ b/ports/stm32/rng.c @@ -66,7 +66,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(pyb_rng_get_obj, pyb_rng_get); // For MCUs that don't have an RNG we still need to provide a rng_get() function, // eg for lwIP and random.seed(). A pseudo-RNG is not really ideal but we go with // it for now, seeding with numbers which will be somewhat different each time. We -// don't want to use urandom's pRNG because then the user won't see a reproducible +// don't want to use random's pRNG because then the user won't see a reproducible // random stream. // Yasmarang random number generator by Ilya Levin diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index f059c21be40..ab06c0fb393 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -364,7 +364,7 @@ STATIC mp_obj_t extra_coverage(void) { mp_repl_autocomplete("import ", 7, &mp_plat_print, &str); len = mp_repl_autocomplete("import ut", 9, &mp_plat_print, &str); mp_printf(&mp_plat_print, "%.*s\n", (int)len, str); - mp_repl_autocomplete("import utime", 12, &mp_plat_print, &str); + mp_repl_autocomplete("import time", 12, &mp_plat_print, &str); mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0))); mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str); diff --git a/ports/unix/modusocket.c b/ports/unix/modusocket.c index 2d4eeec346d..d8a615b4696 100644 --- a/ports/unix/modusocket.c +++ b/ports/unix/modusocket.c @@ -54,11 +54,10 @@ /* The idea of this module is to implement reasonable minimum of socket-related functions to write typical clients and servers. - The module named "usocket" on purpose, to allow to make - Python-level module more (or fully) compatible with CPython - "socket", e.g.: + It's then possible to make a Python-level module more (or fully) + compatible with CPython "socket", e.g.: ---- socket.py ---- - from usocket import * + from socket import * from socket_more_funcs import * from socket_more_funcs2 import * ------------------- @@ -487,7 +486,7 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type_in, size_t n_args, siz return MP_OBJ_FROM_PTR(socket_new(fd)); } -STATIC const mp_rom_map_elem_t usocket_locals_dict_table[] = { +STATIC const mp_rom_map_elem_t socket_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_fileno), MP_ROM_PTR(&socket_fileno_obj) }, { MP_ROM_QSTR(MP_QSTR_makefile), MP_ROM_PTR(&socket_makefile_obj) }, { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) }, @@ -508,9 +507,9 @@ STATIC const mp_rom_map_elem_t usocket_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(usocket_locals_dict, usocket_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(socket_locals_dict, socket_locals_dict_table); -STATIC const mp_stream_p_t usocket_stream_p = { +STATIC const mp_stream_p_t socket_stream_p = { .read = socket_read, .write = socket_write, .ioctl = socket_ioctl, @@ -522,8 +521,8 @@ MP_DEFINE_CONST_OBJ_TYPE( MP_TYPE_FLAG_NONE, make_new, socket_make_new, print, socket_print, - protocol, &usocket_stream_p, - locals_dict, &usocket_locals_dict + protocol, &socket_stream_p, + locals_dict, &socket_locals_dict ); #define BINADDR_MAX_LEN sizeof(struct in6_addr) diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c index 5478b69ad41..eafc915ca4b 100644 --- a/ports/unix/unix_mphal.c +++ b/ports/unix/unix_mphal.c @@ -255,7 +255,7 @@ void mp_hal_get_random(size_t n, void *buf) { #ifdef _HAVE_GETRANDOM RAISE_ERRNO(getrandom(buf, n, 0), errno); #else - int fd = open("/dev/urandom", O_RDONLY); + int fd = open("/dev/random", O_RDONLY); RAISE_ERRNO(fd, errno); RAISE_ERRNO(read(fd, buf, n), errno); close(fd); diff --git a/py/mpconfig.h b/py/mpconfig.h index 9f4d88ec09d..fbe8ba54e2d 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1273,7 +1273,7 @@ typedef double mp_float_t; #define MICROPY_PY_COLLECTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif -// Whether to provide "ucollections.deque" type +// Whether to provide "collections.deque" type #ifndef MICROPY_PY_COLLECTIONS_DEQUE #define MICROPY_PY_COLLECTIONS_DEQUE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif @@ -1458,44 +1458,44 @@ typedef double mp_float_t; #define MICROPY_PY_SYS_ATTR_DELEGATION (MICROPY_PY_SYS_PS1_PS2 || MICROPY_PY_SYS_TRACEBACKLIMIT) #endif -// Whether to provide "uerrno" module +// Whether to provide "errno" module #ifndef MICROPY_PY_UERRNO #define MICROPY_PY_UERRNO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -// Whether to provide the uerrno.errorcode dict +// Whether to provide the errno.errorcode dict #ifndef MICROPY_PY_UERRNO_ERRORCODE #define MICROPY_PY_UERRNO_ERRORCODE (1) #endif -// Whether to provide "uselect" module (baremetal implementation) +// Whether to provide "select" module (baremetal implementation) #ifndef MICROPY_PY_USELECT #define MICROPY_PY_USELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -// Whether to enable the select() function in the "uselect" module (baremetal +// Whether to enable the select() function in the "select" module (baremetal // implementation). This is present for compatibility but can be disabled to // save space. #ifndef MICROPY_PY_USELECT_SELECT #define MICROPY_PY_USELECT_SELECT (1) #endif -// Whether to provide the "utime" module +// Whether to provide the "time" module #ifndef MICROPY_PY_UTIME #define MICROPY_PY_UTIME (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES) #endif -// Whether to provide utime.gmtime/localtime/mktime functions +// Whether to provide time.gmtime/localtime/mktime functions #ifndef MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME #define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (0) #endif -// Whether to provide utime.time/time_ns functions +// Whether to provide time.time/time_ns functions #ifndef MICROPY_PY_UTIME_TIME_TIME_NS #define MICROPY_PY_UTIME_TIME_TIME_NS (0) #endif -// Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu() +// Period of values returned by time.ticks_ms(), ticks_us(), ticks_cpu() // functions. Should be power of two. All functions above use the same // period, so if underlying hardware/API has different periods, the // minimum of them should be used. The value below is the maximum value @@ -1686,7 +1686,7 @@ typedef double mp_float_t; #define MICROPY_PY_USSL (0) #endif -// Whether to add finaliser code to ussl objects +// Whether to add finaliser code to ssl objects #ifndef MICROPY_PY_USSL_FINALISER #define MICROPY_PY_USSL_FINALISER (0) #endif From f5f9edf6457624bf32e71b0c2fdcfbfa5d5753a6 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 18 Aug 2022 15:01:26 +1000 Subject: [PATCH 0012/4300] all: Rename UMODULE to MODULE in preprocessor/Makefile vars. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- docs/library/random.rst | 4 +- examples/natmod/uheapq/uheapq.c | 2 +- examples/natmod/urandom/urandom.c | 6 +- examples/natmod/ure/ure.c | 8 +- examples/natmod/uzlib/uzlib.c | 2 +- extmod/extmod.mk | 4 +- extmod/modlwip.c | 2 +- extmod/modnetwork.h | 2 +- extmod/moduasyncio.c | 6 +- extmod/modubinascii.c | 8 +- extmod/moducryptolib.c | 18 +-- extmod/moduhashlib.c | 24 +-- extmod/moduheapq.c | 4 +- extmod/modujson.c | 6 +- extmod/moduos.c | 34 ++--- extmod/moduplatform.c | 4 +- extmod/moduplatform.h | 2 +- extmod/modurandom.c | 18 +-- extmod/modure.c | 26 ++-- extmod/moduselect.c | 10 +- extmod/modusocket.c | 14 +- extmod/modussl_axtls.c | 8 +- extmod/modussl_mbedtls.c | 8 +- extmod/modutime.c | 40 ++--- extmod/modutimeq.c | 6 +- extmod/moduwebsocket.c | 4 +- extmod/moduzlib.c | 4 +- extmod/uos_dupterm.c | 8 +- extmod/vfs_posix.c | 4 +- extmod/vfs_posix_file.c | 2 +- ports/cc3200/mods/modusocket.c | 2 +- ports/cc3200/mpconfigport.h | 28 ++-- ports/esp32/main.c | 2 +- ports/esp32/modsocket.c | 14 +- ports/esp32/moduos.c | 2 +- ports/esp32/mpconfigport.h | 46 +++--- ports/esp32/mphalport.c | 2 +- ports/esp8266/Makefile | 2 +- ports/esp8266/boards/GENERIC/mpconfigboard.h | 2 +- .../esp8266/boards/GENERIC_1M/mpconfigboard.h | 2 +- .../boards/GENERIC_512K/mpconfigboard.h | 2 +- ports/esp8266/mpconfigport.h | 30 ++-- .../boards/ADAFRUIT_METRO_M7/mpconfigboard.mk | 2 +- .../boards/MIMXRT1020_EVK/mpconfigboard.mk | 2 +- .../boards/MIMXRT1050_EVK/mpconfigboard.mk | 2 +- .../boards/MIMXRT1060_EVK/mpconfigboard.mk | 2 +- .../boards/MIMXRT1064_EVK/mpconfigboard.mk | 2 +- .../boards/MIMXRT1170_EVK/mpconfigboard.mk | 2 +- .../boards/OLIMEX_RT1010/mpconfigboard.h | 2 +- .../boards/SEEED_ARCH_MIX/mpconfigboard.mk | 2 +- ports/mimxrt/boards/TEENSY41/mpconfigboard.mk | 2 +- ports/mimxrt/moduos.c | 4 +- ports/mimxrt/mpconfigport.h | 36 ++--- ports/nrf/boards/evk_nina_b3/mpconfigboard.h | 4 +- ports/nrf/mpconfigport.h | 14 +- ports/qemu-arm/mpconfigport.h | 18 +-- .../boards/EK_RA4M1/mpconfigboard.h | 4 +- .../boards/EK_RA4W1/mpconfigboard.h | 4 +- .../boards/EK_RA6M1/mpconfigboard.h | 4 +- .../boards/EK_RA6M2/mpconfigboard.h | 4 +- .../boards/RA4M1_CLICKER/mpconfigboard.h | 4 +- ports/renesas-ra/mpconfigport.h | 28 ++-- .../mpconfigboard.h | 2 +- ports/rp2/mpconfigport.h | 40 ++--- ports/samd/mcu/samd21/mpconfigmcu.h | 8 +- ports/samd/mcu/samd51/mpconfigmcu.h | 6 +- ports/samd/moduos.c | 8 +- ports/samd/mpconfigport.h | 22 +-- .../boards/ARDUINO_GIGA/mpconfigboard.mk | 2 +- .../ARDUINO_NICLA_VISION/mpconfigboard.mk | 2 +- .../ARDUINO_PORTENTA_H7/mpconfigboard.mk | 2 +- .../boards/B_L072Z_LRWAN1/mpconfigboard.h | 6 +- .../boards/ESPRUINO_PICO/mpconfigboard.h | 2 +- .../boards/NUCLEO_F091RC/mpconfigboard.h | 6 +- .../boards/NUCLEO_F429ZI/mpconfigboard.mk | 2 +- .../boards/NUCLEO_F439ZI/mpconfigboard.mk | 2 +- .../boards/NUCLEO_F746ZG/mpconfigboard.mk | 2 +- .../boards/NUCLEO_F756ZG/mpconfigboard.mk | 2 +- .../boards/NUCLEO_F767ZI/mpconfigboard.mk | 2 +- .../boards/NUCLEO_G474RE/mpconfigboard.h | 12 +- .../boards/NUCLEO_H723ZG/mpconfigboard.mk | 2 +- .../boards/NUCLEO_H743ZI/mpconfigboard.mk | 2 +- .../boards/NUCLEO_L073RZ/mpconfigboard.h | 6 +- .../boards/NUCLEO_L432KC/mpconfigboard.h | 6 +- .../boards/NUCLEO_L452RE/mpconfigboard.h | 2 +- .../stm32/boards/NUCLEO_WL55/mpconfigboard.h | 6 +- .../stm32/boards/OLIMEX_E407/mpconfigboard.mk | 2 +- ports/stm32/boards/PYBD_SF2/mpconfigboard.mk | 2 +- ports/stm32/boards/PYBD_SF3/mpconfigboard.mk | 2 +- ports/stm32/boards/PYBD_SF6/mpconfigboard.mk | 2 +- .../boards/STM32F769DISC/mpconfigboard.mk | 2 +- .../stm32/boards/STM32F7DISC/mpconfigboard.mk | 2 +- .../boards/VCC_GND_F407ZG/mpconfigboard.mk | 2 +- ports/stm32/moduos.c | 2 +- ports/stm32/mpconfigport.h | 46 +++--- ports/unix/Makefile | 2 +- ports/unix/README.md | 2 +- ports/unix/mbedtls/mbedtls_config.h | 2 +- ports/unix/moduselect.c | 8 +- ports/unix/modusocket.c | 4 +- ports/unix/modutime.c | 2 +- ports/unix/mpconfigport.h | 4 +- ports/unix/mpconfigport.mk | 4 +- .../unix/variants/coverage/mpconfigvariant.h | 2 +- ports/unix/variants/minimal/mpconfigvariant.h | 2 +- .../unix/variants/minimal/mpconfigvariant.mk | 2 +- ports/unix/variants/mpconfigvariant_common.h | 42 ++--- ports/windows/mpconfigport.h | 44 +++--- ports/windows/variants/dev/mpconfigvariant.h | 4 +- ports/zephyr/modusocket.c | 6 +- ports/zephyr/modzsensor.c | 2 +- ports/zephyr/mpconfigport.h | 16 +- ports/zephyr/prj.conf | 2 +- py/moduerrno.c | 18 +-- py/mpconfig.h | 144 +++++++++--------- py/mperrno.h | 2 +- py/objbool.c | 2 +- py/objdict.c | 6 +- py/objexcept.c | 2 +- py/objlist.c | 4 +- py/objnone.c | 2 +- py/objstr.c | 4 +- py/objstrunicode.c | 2 +- py/objtuple.c | 6 +- py/parse.c | 2 +- tools/ci.sh | 4 +- 126 files changed, 563 insertions(+), 563 deletions(-) diff --git a/docs/library/random.rst b/docs/library/random.rst index dd8b47c80f0..be56eb088ea 100644 --- a/docs/library/random.rst +++ b/docs/library/random.rst @@ -24,7 +24,7 @@ This module implements a pseudo-random number generator (PRNG). .. note:: The :func:`randrange`, :func:`randint` and :func:`choice` functions are only - available if the ``MICROPY_PY_URANDOM_EXTRA_FUNCS`` configuration option is + available if the ``MICROPY_PY_RANDOM_EXTRA_FUNCS`` configuration option is enabled. @@ -73,7 +73,7 @@ Other Functions supported by the port) initialise the PRNG with a true random number (usually a hardware generated random number). - The ``None`` case only works if ``MICROPY_PY_URANDOM_SEED_INIT_FUNC`` is + The ``None`` case only works if ``MICROPY_PY_RANDOM_SEED_INIT_FUNC`` is enabled by the port, otherwise it raises ``ValueError``. .. function:: choice(sequence) diff --git a/examples/natmod/uheapq/uheapq.c b/examples/natmod/uheapq/uheapq.c index ff70bef479e..e339ccafd77 100644 --- a/examples/natmod/uheapq/uheapq.c +++ b/examples/natmod/uheapq/uheapq.c @@ -1,4 +1,4 @@ -#define MICROPY_PY_UHEAPQ (1) +#define MICROPY_PY_HEAPQ (1) #include "py/dynruntime.h" diff --git a/examples/natmod/urandom/urandom.c b/examples/natmod/urandom/urandom.c index 0c4e88c77e7..ed46651b342 100644 --- a/examples/natmod/urandom/urandom.c +++ b/examples/natmod/urandom/urandom.c @@ -1,5 +1,5 @@ -#define MICROPY_PY_URANDOM (1) -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) +#define MICROPY_PY_RANDOM (1) +#define MICROPY_PY_RANDOM_EXTRA_FUNCS (1) #include "py/dynruntime.h" @@ -19,7 +19,7 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_random)); mp_store_global(MP_QSTR_getrandbits, MP_OBJ_FROM_PTR(&mod_random_getrandbits_obj)); mp_store_global(MP_QSTR_seed, MP_OBJ_FROM_PTR(&mod_random_seed_obj)); - #if MICROPY_PY_URANDOM_EXTRA_FUNCS + #if MICROPY_PY_RANDOM_EXTRA_FUNCS mp_store_global(MP_QSTR_randrange, MP_OBJ_FROM_PTR(&mod_random_randrange_obj)); mp_store_global(MP_QSTR_randint, MP_OBJ_FROM_PTR(&mod_random_randint_obj)); mp_store_global(MP_QSTR_choice, MP_OBJ_FROM_PTR(&mod_random_choice_obj)); diff --git a/examples/natmod/ure/ure.c b/examples/natmod/ure/ure.c index c51df2a4759..79eca90ab9e 100644 --- a/examples/natmod/ure/ure.c +++ b/examples/natmod/ure/ure.c @@ -1,8 +1,8 @@ #define MICROPY_STACK_CHECK (1) -#define MICROPY_PY_URE (1) -#define MICROPY_PY_URE_MATCH_GROUPS (1) -#define MICROPY_PY_URE_MATCH_SPAN_START_END (1) -#define MICROPY_PY_URE_SUB (0) // requires vstr interface +#define MICROPY_PY_RE (1) +#define MICROPY_PY_RE_MATCH_GROUPS (1) +#define MICROPY_PY_RE_MATCH_SPAN_START_END (1) +#define MICROPY_PY_RE_SUB (0) // requires vstr interface #include #include "py/dynruntime.h" diff --git a/examples/natmod/uzlib/uzlib.c b/examples/natmod/uzlib/uzlib.c index ea21235102d..9a3ec0af3c8 100644 --- a/examples/natmod/uzlib/uzlib.c +++ b/examples/natmod/uzlib/uzlib.c @@ -1,4 +1,4 @@ -#define MICROPY_PY_UZLIB (1) +#define MICROPY_PY_ZLIB (1) #include "py/dynruntime.h" diff --git a/extmod/extmod.mk b/extmod/extmod.mk index ee9372e18d9..2f9bd3b065d 100644 --- a/extmod/extmod.mk +++ b/extmod/extmod.mk @@ -108,8 +108,8 @@ endif ################################################################################ # ussl -ifeq ($(MICROPY_PY_USSL),1) -CFLAGS_EXTMOD += -DMICROPY_PY_USSL=1 +ifeq ($(MICROPY_PY_SSL),1) +CFLAGS_EXTMOD += -DMICROPY_PY_SSL=1 ifeq ($(MICROPY_SSL_AXTLS),1) AXTLS_DIR = lib/axtls GIT_SUBMODULES += $(AXTLS_DIR) diff --git a/extmod/modlwip.c b/extmod/modlwip.c index c66a1de1961..a902e8fb0fe 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -918,7 +918,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_bind_obj, lwip_socket_bind); STATIC mp_obj_t lwip_socket_listen(size_t n_args, const mp_obj_t *args) { lwip_socket_obj_t *socket = MP_OBJ_TO_PTR(args[0]); - mp_int_t backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT; + mp_int_t backlog = MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT; if (n_args > 1) { backlog = mp_obj_get_int(args[1]); backlog = (backlog < 0) ? 0 : backlog; diff --git a/extmod/modnetwork.h b/extmod/modnetwork.h index 11691140fd6..4786596e9b9 100644 --- a/extmod/modnetwork.h +++ b/extmod/modnetwork.h @@ -101,7 +101,7 @@ typedef struct _mod_network_socket_obj_t { int32_t timeout; mp_obj_t callback; int32_t state : 8; - #if MICROPY_PY_USOCKET_EXTENDED_STATE + #if MICROPY_PY_SOCKET_EXTENDED_STATE // Extended socket state for NICs/ports that need it. void *_private; #endif diff --git a/extmod/moduasyncio.c b/extmod/moduasyncio.c index 021e0da1be2..c05a8dfc609 100644 --- a/extmod/moduasyncio.c +++ b/extmod/moduasyncio.c @@ -64,14 +64,14 @@ STATIC mp_obj_t task_queue_make_new(const mp_obj_type_t *type, size_t n_args, si // Ticks for task ordering in pairing heap STATIC mp_obj_t ticks(void) { - return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); + return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_TIME_TICKS_PERIOD - 1)); } STATIC mp_int_t ticks_diff(mp_obj_t t1_in, mp_obj_t t0_in) { mp_uint_t t0 = MP_OBJ_SMALL_INT_VALUE(t0_in); mp_uint_t t1 = MP_OBJ_SMALL_INT_VALUE(t1_in); - mp_int_t diff = ((t1 - t0 + MICROPY_PY_UTIME_TICKS_PERIOD / 2) & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)) - - MICROPY_PY_UTIME_TICKS_PERIOD / 2; + mp_int_t diff = ((t1 - t0 + MICROPY_PY_TIME_TICKS_PERIOD / 2) & (MICROPY_PY_TIME_TICKS_PERIOD - 1)) + - MICROPY_PY_TIME_TICKS_PERIOD / 2; return diff; } diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index bfb8195d919..af8eab79f0a 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -32,7 +32,7 @@ #include "py/binary.h" #include "py/objstr.h" -#if MICROPY_PY_UBINASCII +#if MICROPY_PY_BINASCII #if MICROPY_PY_BUILTINS_BYTES_HEX STATIC mp_obj_t bytes_hex_as_bytes(size_t n_args, const mp_obj_t *args) { @@ -170,7 +170,7 @@ STATIC mp_obj_t mod_binascii_b2a_base64(size_t n_args, const mp_obj_t *pos_args, } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_binascii_b2a_base64_obj, 1, mod_binascii_b2a_base64); -#if MICROPY_PY_UBINASCII_CRC32 +#if MICROPY_PY_BINASCII_CRC32 #include "lib/uzlib/tinf.h" STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) { @@ -191,7 +191,7 @@ STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { #endif { MP_ROM_QSTR(MP_QSTR_a2b_base64), MP_ROM_PTR(&mod_binascii_a2b_base64_obj) }, { MP_ROM_QSTR(MP_QSTR_b2a_base64), MP_ROM_PTR(&mod_binascii_b2a_base64_obj) }, - #if MICROPY_PY_UBINASCII_CRC32 + #if MICROPY_PY_BINASCII_CRC32 { MP_ROM_QSTR(MP_QSTR_crc32), MP_ROM_PTR(&mod_binascii_crc32_obj) }, #endif }; @@ -205,4 +205,4 @@ const mp_obj_module_t mp_module_binascii = { MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_binascii); -#endif // MICROPY_PY_UBINASCII +#endif // MICROPY_PY_BINASCII diff --git a/extmod/moducryptolib.c b/extmod/moducryptolib.c index 0c9701024ee..22994772599 100644 --- a/extmod/moducryptolib.c +++ b/extmod/moducryptolib.c @@ -27,7 +27,7 @@ #include "py/mpconfig.h" -#if MICROPY_PY_UCRYPTOLIB +#if MICROPY_PY_CRYPTOLIB #include #include @@ -90,7 +90,7 @@ typedef struct _mp_obj_aes_t { } mp_obj_aes_t; static inline bool is_ctr_mode(int block_mode) { - #if MICROPY_PY_UCRYPTOLIB_CTR + #if MICROPY_PY_CRYPTOLIB_CTR return block_mode == UCRYPTOLIB_MODE_CTR; #else return false; @@ -140,7 +140,7 @@ STATIC void aes_process_cbc_impl(AES_CTX_IMPL *ctx, const uint8_t *in, uint8_t * } } -#if MICROPY_PY_UCRYPTOLIB_CTR +#if MICROPY_PY_CRYPTOLIB_CTR // axTLS doesn't have CTR support out of the box. This implements the counter part using the ECB primitive. STATIC void aes_process_ctr_impl(AES_CTX_IMPL *ctx, const uint8_t *in, uint8_t *out, size_t in_len, struct ctr_params *ctr_params) { size_t n = ctr_params->offset; @@ -203,7 +203,7 @@ STATIC void aes_process_cbc_impl(AES_CTX_IMPL *ctx, const uint8_t *in, uint8_t * mbedtls_aes_crypt_cbc(&ctx->u.mbedtls_ctx, encrypt ? MBEDTLS_AES_ENCRYPT : MBEDTLS_AES_DECRYPT, in_len, ctx->iv, in, out); } -#if MICROPY_PY_UCRYPTOLIB_CTR +#if MICROPY_PY_CRYPTOLIB_CTR STATIC void aes_process_ctr_impl(AES_CTX_IMPL *ctx, const uint8_t *in, uint8_t *out, size_t in_len, struct ctr_params *ctr_params) { mbedtls_aes_crypt_ctr(&ctx->u.mbedtls_ctx, in_len, &ctr_params->offset, ctx->iv, ctr_params->encrypted_counter, in, out); } @@ -219,7 +219,7 @@ STATIC mp_obj_t cryptolib_aes_make_new(const mp_obj_type_t *type, size_t n_args, switch (block_mode) { case UCRYPTOLIB_MODE_ECB: case UCRYPTOLIB_MODE_CBC: - #if MICROPY_PY_UCRYPTOLIB_CTR + #if MICROPY_PY_CRYPTOLIB_CTR case UCRYPTOLIB_MODE_CTR: #endif break; @@ -318,7 +318,7 @@ STATIC mp_obj_t aes_process(size_t n_args, const mp_obj_t *args, bool encrypt) { aes_process_cbc_impl(&self->ctx, in_bufinfo.buf, out_buf_ptr, in_bufinfo.len, encrypt); break; - #if MICROPY_PY_UCRYPTOLIB_CTR + #if MICROPY_PY_CRYPTOLIB_CTR case UCRYPTOLIB_MODE_CTR: aes_process_ctr_impl(&self->ctx, in_bufinfo.buf, out_buf_ptr, in_bufinfo.len, ctr_params_from_aes(self)); @@ -359,10 +359,10 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( STATIC const mp_rom_map_elem_t mp_module_cryptolib_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cryptolib) }, { MP_ROM_QSTR(MP_QSTR_aes), MP_ROM_PTR(&cryptolib_aes_type) }, - #if MICROPY_PY_UCRYPTOLIB_CONSTS + #if MICROPY_PY_CRYPTOLIB_CONSTS { MP_ROM_QSTR(MP_QSTR_MODE_ECB), MP_ROM_INT(UCRYPTOLIB_MODE_ECB) }, { MP_ROM_QSTR(MP_QSTR_MODE_CBC), MP_ROM_INT(UCRYPTOLIB_MODE_CBC) }, - #if MICROPY_PY_UCRYPTOLIB_CTR + #if MICROPY_PY_CRYPTOLIB_CTR { MP_ROM_QSTR(MP_QSTR_MODE_CTR), MP_ROM_INT(UCRYPTOLIB_MODE_CTR) }, #endif #endif @@ -377,4 +377,4 @@ const mp_obj_module_t mp_module_cryptolib = { MP_REGISTER_MODULE(MP_QSTR_cryptolib, mp_module_cryptolib); -#endif // MICROPY_PY_UCRYPTOLIB +#endif // MICROPY_PY_CRYPTOLIB diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index 0e01b4f27f9..1b94cc01a04 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -29,13 +29,13 @@ #include "py/runtime.h" -#if MICROPY_PY_UHASHLIB +#if MICROPY_PY_HASHLIB #if MICROPY_SSL_MBEDTLS #include "mbedtls/version.h" #endif -#if MICROPY_PY_UHASHLIB_SHA256 +#if MICROPY_PY_HASHLIB_SHA256 #if MICROPY_SSL_MBEDTLS #include "mbedtls/sha256.h" @@ -45,7 +45,7 @@ #endif -#if MICROPY_PY_UHASHLIB_SHA1 || MICROPY_PY_UHASHLIB_MD5 +#if MICROPY_PY_HASHLIB_SHA1 || MICROPY_PY_HASHLIB_MD5 #if MICROPY_SSL_AXTLS #include "lib/axtls/crypto/crypto.h" @@ -70,7 +70,7 @@ static void hashlib_ensure_not_final(mp_obj_hash_t *self) { } } -#if MICROPY_PY_UHASHLIB_SHA256 +#if MICROPY_PY_HASHLIB_SHA256 STATIC mp_obj_t hashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg); #if MICROPY_SSL_MBEDTLS @@ -161,12 +161,12 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( hashlib_sha256_type, MP_QSTR_sha256, MP_TYPE_FLAG_NONE, - make_new, uhashlib_sha256_make_new, + make_new, hashlib_sha256_make_new, locals_dict, &hashlib_sha256_locals_dict ); #endif -#if MICROPY_PY_UHASHLIB_SHA1 +#if MICROPY_PY_HASHLIB_SHA1 STATIC mp_obj_t hashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg); #if MICROPY_SSL_AXTLS @@ -260,7 +260,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( ); #endif -#if MICROPY_PY_UHASHLIB_MD5 +#if MICROPY_PY_HASHLIB_MD5 STATIC mp_obj_t hashlib_md5_update(mp_obj_t self_in, mp_obj_t arg); #if MICROPY_SSL_AXTLS @@ -352,17 +352,17 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE( make_new, hashlib_md5_make_new, locals_dict, &hashlib_md5_locals_dict ); -#endif // MICROPY_PY_UHASHLIB_MD5 +#endif // MICROPY_PY_HASHLIB_MD5 STATIC const mp_rom_map_elem_t mp_module_hashlib_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_hashlib) }, - #if MICROPY_PY_UHASHLIB_SHA256 + #if MICROPY_PY_HASHLIB_SHA256 { MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&hashlib_sha256_type) }, #endif - #if MICROPY_PY_UHASHLIB_SHA1 + #if MICROPY_PY_HASHLIB_SHA1 { MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&hashlib_sha1_type) }, #endif - #if MICROPY_PY_UHASHLIB_MD5 + #if MICROPY_PY_HASHLIB_MD5 { MP_ROM_QSTR(MP_QSTR_md5), MP_ROM_PTR(&hashlib_md5_type) }, #endif }; @@ -376,4 +376,4 @@ const mp_obj_module_t mp_module_hashlib = { MP_REGISTER_MODULE(MP_QSTR_hashlib, mp_module_hashlib); -#endif // MICROPY_PY_UHASHLIB +#endif // MICROPY_PY_HASHLIB diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c index 59277813e95..79a12c2b9c5 100644 --- a/extmod/moduheapq.c +++ b/extmod/moduheapq.c @@ -27,7 +27,7 @@ #include "py/objlist.h" #include "py/runtime.h" -#if MICROPY_PY_UHEAPQ +#if MICROPY_PY_HEAPQ // the algorithm here is modelled on CPython's heapq.py @@ -121,4 +121,4 @@ const mp_obj_module_t mp_module_heapq = { MP_REGISTER_MODULE(MP_QSTR_heapq, mp_module_heapq); #endif -#endif // MICROPY_PY_UHEAPQ +#endif // MICROPY_PY_HEAPQ diff --git a/extmod/modujson.c b/extmod/modujson.c index e67761e1a99..1b475543e16 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -32,9 +32,9 @@ #include "py/runtime.h" #include "py/stream.h" -#if MICROPY_PY_UJSON +#if MICROPY_PY_JSON -#if MICROPY_PY_UJSON_SEPARATORS +#if MICROPY_PY_JSON_SEPARATORS enum { DUMP_MODE_TO_STRING = 1, @@ -383,4 +383,4 @@ const mp_obj_module_t mp_module_json = { MP_REGISTER_MODULE(MP_QSTR_json, mp_module_json); -#endif // MICROPY_PY_UJSON +#endif // MICROPY_PY_JSON diff --git a/extmod/moduos.c b/extmod/moduos.c index 8c40f453703..e962a6c1718 100644 --- a/extmod/moduos.c +++ b/extmod/moduos.c @@ -27,14 +27,14 @@ #include "py/objstr.h" #include "py/runtime.h" -#if MICROPY_PY_UOS +#if MICROPY_PY_OS #include "extmod/misc.h" #include "extmod/vfs.h" #if MICROPY_VFS_FAT #include "extmod/vfs_fat.h" -#if MICROPY_PY_UOS_SYNC +#if MICROPY_PY_OS_SYNC #include "lib/oofatfs/ff.h" #include "lib/oofatfs/diskio.h" #endif @@ -48,12 +48,12 @@ #include "extmod/vfs_posix.h" #endif -#if MICROPY_PY_UOS_UNAME +#if MICROPY_PY_OS_UNAME #include "genhdr/mpversion.h" #endif -#ifdef MICROPY_PY_UOS_INCLUDEFILE -#include MICROPY_PY_UOS_INCLUDEFILE +#ifdef MICROPY_PY_OS_INCLUDEFILE +#include MICROPY_PY_OS_INCLUDEFILE #endif #ifdef MICROPY_BUILD_TYPE @@ -62,7 +62,7 @@ #define MICROPY_BUILD_TYPE_PAREN #endif -#if MICROPY_PY_UOS_SYNC +#if MICROPY_PY_OS_SYNC // sync() // Sync all filesystems. STATIC mp_obj_t mp_os_sync(void) { @@ -77,9 +77,9 @@ STATIC mp_obj_t mp_os_sync(void) { MP_DEFINE_CONST_FUN_OBJ_0(mp_os_sync_obj, mp_os_sync); #endif -#if MICROPY_PY_UOS_UNAME +#if MICROPY_PY_OS_UNAME -#if MICROPY_PY_UOS_UNAME_RELEASE_DYNAMIC +#if MICROPY_PY_OS_UNAME_RELEASE_DYNAMIC #define CONST_RELEASE #else #define CONST_RELEASE const @@ -110,7 +110,7 @@ STATIC MP_DEFINE_ATTRTUPLE( ); STATIC mp_obj_t mp_os_uname(void) { - #if MICROPY_PY_UOS_UNAME_RELEASE_DYNAMIC + #if MICROPY_PY_OS_UNAME_RELEASE_DYNAMIC const char *release = mp_os_uname_release(); mp_os_uname_info_release_obj.len = strlen(release); mp_os_uname_info_release_obj.data = (const byte *)release; @@ -124,21 +124,21 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_os_uname_obj, mp_os_uname); STATIC const mp_rom_map_elem_t os_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_os) }, - #if MICROPY_PY_UOS_GETENV_PUTENV_UNSETENV + #if MICROPY_PY_OS_GETENV_PUTENV_UNSETENV { MP_ROM_QSTR(MP_QSTR_getenv), MP_ROM_PTR(&mp_os_getenv_obj) }, { MP_ROM_QSTR(MP_QSTR_putenv), MP_ROM_PTR(&mp_os_putenv_obj) }, { MP_ROM_QSTR(MP_QSTR_unsetenv), MP_ROM_PTR(&mp_os_unsetenv_obj) }, #endif - #if MICROPY_PY_UOS_SEP + #if MICROPY_PY_OS_SEP { MP_ROM_QSTR(MP_QSTR_sep), MP_ROM_QSTR(MP_QSTR__slash_) }, #endif - #if MICROPY_PY_UOS_SYNC + #if MICROPY_PY_OS_SYNC { MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&mp_os_sync_obj) }, #endif - #if MICROPY_PY_UOS_SYSTEM + #if MICROPY_PY_OS_SYSTEM { MP_ROM_QSTR(MP_QSTR_system), MP_ROM_PTR(&mp_os_system_obj) }, #endif - #if MICROPY_PY_UOS_UNAME + #if MICROPY_PY_OS_UNAME { MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&mp_os_uname_obj) }, #endif #if MICROPY_PY_OS_URANDOM @@ -163,10 +163,10 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { #if MICROPY_PY_OS_DUPTERM { MP_ROM_QSTR(MP_QSTR_dupterm), MP_ROM_PTR(&mp_os_dupterm_obj) }, #endif - #if MICROPY_PY_UOS_DUPTERM_NOTIFY + #if MICROPY_PY_OS_DUPTERM_NOTIFY { MP_ROM_QSTR(MP_QSTR_dupterm_notify), MP_ROM_PTR(&mp_os_dupterm_notify_obj) }, #endif - #if MICROPY_PY_UOS_ERRNO + #if MICROPY_PY_OS_ERRNO { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_os_errno_obj) }, #endif @@ -197,4 +197,4 @@ const mp_obj_module_t mp_module_os = { MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os); -#endif // MICROPY_PY_UOS +#endif // MICROPY_PY_OS diff --git a/extmod/moduplatform.c b/extmod/moduplatform.c index 791ae8344d9..d5f919fc5e0 100644 --- a/extmod/moduplatform.c +++ b/extmod/moduplatform.c @@ -32,7 +32,7 @@ #include "extmod/moduplatform.h" #include "genhdr/mpversion.h" -#if MICROPY_PY_UPLATFORM +#if MICROPY_PY_PLATFORM // platform - Access to underlying platform's identifying data @@ -77,4 +77,4 @@ const mp_obj_module_t mp_module_platform = { MP_REGISTER_MODULE(MP_QSTR_platform, mp_module_platform); -#endif // MICROPY_PY_UPLATFORM +#endif // MICROPY_PY_PLATFORM diff --git a/extmod/moduplatform.h b/extmod/moduplatform.h index 3597f7559f5..7ca42977889 100644 --- a/extmod/moduplatform.h +++ b/extmod/moduplatform.h @@ -30,7 +30,7 @@ #include "py/mpconfig.h" // Preprocessor directives identifying the platform. -// The (u)platform module itself is guarded by MICROPY_PY_UPLATFORM, see the +// The platform module itself is guarded by MICROPY_PY_PLATFORM, see the // .c file, but these are made available because they're generally usable. // TODO: Add more architectures, compilers and libraries. // See: https://sourceforge.net/p/predef/wiki/Home/ diff --git a/extmod/modurandom.c b/extmod/modurandom.c index f69f7f41933..1c697aec70d 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -29,10 +29,10 @@ #include "py/runtime.h" -#if MICROPY_PY_URANDOM +#if MICROPY_PY_RANDOM // Work out if the seed will be set on import or not. -#if MICROPY_MODULE_BUILTIN_INIT && defined(MICROPY_PY_URANDOM_SEED_INIT_FUNC) +#if MICROPY_MODULE_BUILTIN_INIT && defined(MICROPY_PY_RANDOM_SEED_INIT_FUNC) #define SEED_ON_IMPORT (1) #else #define SEED_ON_IMPORT (0) @@ -67,7 +67,7 @@ STATIC uint32_t yasmarang(void) { // End of Yasmarang -#if MICROPY_PY_URANDOM_EXTRA_FUNCS +#if MICROPY_PY_RANDOM_EXTRA_FUNCS // returns an unsigned integer below the given argument // n must not be zero @@ -103,8 +103,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_getrandbits_obj, mod_random_getrandb STATIC mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) { mp_uint_t seed; if (n_args == 0 || args[0] == mp_const_none) { - #ifdef MICROPY_PY_URANDOM_SEED_INIT_FUNC - seed = MICROPY_PY_URANDOM_SEED_INIT_FUNC; + #ifdef MICROPY_PY_RANDOM_SEED_INIT_FUNC + seed = MICROPY_PY_RANDOM_SEED_INIT_FUNC; #else mp_raise_ValueError(MP_ERROR_TEXT("no default seed")); #endif @@ -119,7 +119,7 @@ STATIC mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_seed_obj, 0, 1, mod_random_seed); -#if MICROPY_PY_URANDOM_EXTRA_FUNCS +#if MICROPY_PY_RANDOM_EXTRA_FUNCS STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) { mp_int_t start = mp_obj_get_int(args[0]); @@ -213,7 +213,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_uniform_obj, mod_random_uniform); #endif -#endif // MICROPY_PY_URANDOM_EXTRA_FUNCS +#endif // MICROPY_PY_RANDOM_EXTRA_FUNCS #if SEED_ON_IMPORT STATIC mp_obj_t mod_random___init__(void) { @@ -237,7 +237,7 @@ STATIC const mp_rom_map_elem_t mp_module_random_globals_table[] = { #endif { MP_ROM_QSTR(MP_QSTR_getrandbits), MP_ROM_PTR(&mod_random_getrandbits_obj) }, { MP_ROM_QSTR(MP_QSTR_seed), MP_ROM_PTR(&mod_random_seed_obj) }, - #if MICROPY_PY_URANDOM_EXTRA_FUNCS + #if MICROPY_PY_RANDOM_EXTRA_FUNCS { MP_ROM_QSTR(MP_QSTR_randrange), MP_ROM_PTR(&mod_random_randrange_obj) }, { MP_ROM_QSTR(MP_QSTR_randint), MP_ROM_PTR(&mod_random_randint_obj) }, { MP_ROM_QSTR(MP_QSTR_choice), MP_ROM_PTR(&mod_random_choice_obj) }, @@ -258,4 +258,4 @@ const mp_obj_module_t mp_module_random = { MP_REGISTER_MODULE(MP_QSTR_random, mp_module_random); #endif -#endif // MICROPY_PY_URANDOM +#endif // MICROPY_PY_RANDOM diff --git a/extmod/modure.c b/extmod/modure.c index a6fad3cf4ee..c8a019be891 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -37,7 +37,7 @@ #include "py/unicode.h" #endif -#if MICROPY_PY_URE +#if MICROPY_PY_RE #define re1_5_stack_chk() MP_STACK_CHECK() @@ -85,7 +85,7 @@ STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) { } MP_DEFINE_CONST_FUN_OBJ_2(match_group_obj, match_group); -#if MICROPY_PY_URE_MATCH_GROUPS +#if MICROPY_PY_RE_MATCH_GROUPS STATIC mp_obj_t match_groups(mp_obj_t self_in) { mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in); @@ -102,7 +102,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(match_groups_obj, match_groups); #endif -#if MICROPY_PY_URE_MATCH_SPAN_START_END +#if MICROPY_PY_RE_MATCH_SPAN_START_END STATIC void match_span_helper(size_t n_args, const mp_obj_t *args, mp_obj_t span[2]) { mp_obj_match_t *self = MP_OBJ_TO_PTR(args[0]); @@ -167,10 +167,10 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(match_end_obj, 1, 2, match_end); #if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_rom_map_elem_t match_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_group), MP_ROM_PTR(&match_group_obj) }, - #if MICROPY_PY_URE_MATCH_GROUPS + #if MICROPY_PY_RE_MATCH_GROUPS { MP_ROM_QSTR(MP_QSTR_groups), MP_ROM_PTR(&match_groups_obj) }, #endif - #if MICROPY_PY_URE_MATCH_SPAN_START_END + #if MICROPY_PY_RE_MATCH_SPAN_START_END { MP_ROM_QSTR(MP_QSTR_span), MP_ROM_PTR(&match_span_obj) }, { MP_ROM_QSTR(MP_QSTR_start), MP_ROM_PTR(&match_start_obj) }, { MP_ROM_QSTR(MP_QSTR_end), MP_ROM_PTR(&match_end_obj) }, @@ -277,7 +277,7 @@ STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) { } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_split_obj, 2, 3, re_split); -#if MICROPY_PY_URE_SUB +#if MICROPY_PY_RE_SUB STATIC mp_obj_t re_sub_helper(size_t n_args, const mp_obj_t *args) { mp_obj_re_t *self; @@ -405,7 +405,7 @@ STATIC const mp_rom_map_elem_t re_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_match), MP_ROM_PTR(&re_match_obj) }, { MP_ROM_QSTR(MP_QSTR_search), MP_ROM_PTR(&re_search_obj) }, { MP_ROM_QSTR(MP_QSTR_split), MP_ROM_PTR(&re_split_obj) }, - #if MICROPY_PY_URE_SUB + #if MICROPY_PY_RE_SUB { MP_ROM_QSTR(MP_QSTR_sub), MP_ROM_PTR(&re_sub_obj) }, #endif }; @@ -429,7 +429,7 @@ STATIC mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) { goto error; } mp_obj_re_t *o = mp_obj_malloc_var(mp_obj_re_t, char, size, (mp_obj_type_t *)&re_type); - #if MICROPY_PY_URE_DEBUG + #if MICROPY_PY_RE_DEBUG int flags = 0; if (n_args > 1) { flags = mp_obj_get_int(args[1]); @@ -440,7 +440,7 @@ STATIC mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) { error: mp_raise_ValueError(MP_ERROR_TEXT("error in regex")); } - #if MICROPY_PY_URE_DEBUG + #if MICROPY_PY_RE_DEBUG if (flags & FLAG_DEBUG) { re1_5_dumpcode(&o->re); } @@ -455,10 +455,10 @@ STATIC const mp_rom_map_elem_t mp_module_re_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_compile), MP_ROM_PTR(&mod_re_compile_obj) }, { MP_ROM_QSTR(MP_QSTR_match), MP_ROM_PTR(&re_match_obj) }, { MP_ROM_QSTR(MP_QSTR_search), MP_ROM_PTR(&re_search_obj) }, - #if MICROPY_PY_URE_SUB + #if MICROPY_PY_RE_SUB { MP_ROM_QSTR(MP_QSTR_sub), MP_ROM_PTR(&re_sub_obj) }, #endif - #if MICROPY_PY_URE_DEBUG + #if MICROPY_PY_RE_DEBUG { MP_ROM_QSTR(MP_QSTR_DEBUG), MP_ROM_INT(FLAG_DEBUG) }, #endif }; @@ -482,11 +482,11 @@ MP_REGISTER_MODULE(MP_QSTR_re, mp_module_re); #include "lib/re1.5/recursiveloop.c" #include "lib/re1.5/charclass.c" -#if MICROPY_PY_URE_DEBUG +#if MICROPY_PY_RE_DEBUG // Make sure the output print statements go to the same output as other Python output. #define printf(...) mp_printf(&mp_plat_print, __VA_ARGS__) #include "lib/re1.5/dumpcode.c" #undef printf #endif -#endif // MICROPY_PY_URE +#endif // MICROPY_PY_RE diff --git a/extmod/moduselect.c b/extmod/moduselect.c index 5bb5f4f48df..011d5cb832c 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -26,7 +26,7 @@ */ #include "py/mpconfig.h" -#if MICROPY_PY_USELECT +#if MICROPY_PY_SELECT #include @@ -107,7 +107,7 @@ STATIC mp_uint_t poll_map_poll(mp_map_t *poll_map, size_t *rwx_num) { return n_ready; } -#if MICROPY_PY_USELECT_SELECT +#if MICROPY_PY_SELECT_SELECT // select(rlist, wlist, xlist[, timeout]) STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) { // get array data from tuple/list arguments @@ -174,7 +174,7 @@ STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) { } } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select); -#endif // MICROPY_PY_USELECT_SELECT +#endif // MICROPY_PY_SELECT_SELECT typedef struct _mp_obj_poll_t { mp_obj_base_t base; @@ -356,7 +356,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll); STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_select) }, - #if MICROPY_PY_USELECT_SELECT + #if MICROPY_PY_SELECT_SELECT { MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_select_select_obj) }, #endif { MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_select_poll_obj) }, @@ -375,4 +375,4 @@ const mp_obj_module_t mp_module_select = { MP_REGISTER_MODULE(MP_QSTR_select, mp_module_select); -#endif // MICROPY_PY_USELECT +#endif // MICROPY_PY_SELECT diff --git a/extmod/modusocket.c b/extmod/modusocket.c index c8695f10448..316a578ac20 100644 --- a/extmod/modusocket.c +++ b/extmod/modusocket.c @@ -33,7 +33,7 @@ #include "py/stream.h" #include "py/mperrno.h" -#if MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP +#if MICROPY_PY_NETWORK && MICROPY_PY_SOCKET && !MICROPY_PY_LWIP #include "shared/netutils/netutils.h" #include "modnetwork.h" @@ -75,7 +75,7 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, size_t s->timeout = -1; s->callback = MP_OBJ_NULL; s->state = MOD_NETWORK_SS_NEW; - #if MICROPY_PY_USOCKET_EXTENDED_STATE + #if MICROPY_PY_SOCKET_EXTENDED_STATE s->_private = NULL; #endif @@ -94,7 +94,7 @@ STATIC void socket_select_nic(mod_network_socket_obj_t *self, const byte *ip) { mp_raise_OSError(_errno); } - #if MICROPY_PY_USOCKET_EXTENDED_STATE + #if MICROPY_PY_SOCKET_EXTENDED_STATE // if a timeout was set before binding a NIC, call settimeout to reset it if (self->timeout != -1 && self->nic_protocol->settimeout(self, self->timeout, &_errno) != 0) { mp_raise_OSError(_errno); @@ -134,7 +134,7 @@ STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) { mp_raise_OSError(MP_ENOTCONN); } - mp_int_t backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT; + mp_int_t backlog = MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT; if (n_args > 1) { backlog = mp_obj_get_int(args[1]); backlog = (backlog < 0) ? 0 : backlog; @@ -177,7 +177,7 @@ STATIC mp_obj_t socket_accept(mp_obj_t self_in) { socket2->timeout = -1; socket2->callback = MP_OBJ_NULL; socket2->state = MOD_NETWORK_SS_NEW; - #if MICROPY_PY_USOCKET_EXTENDED_STATE + #if MICROPY_PY_SOCKET_EXTENDED_STATE socket2->_private = NULL; #endif @@ -420,7 +420,7 @@ STATIC mp_obj_t socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) { #endif } if (self->nic == MP_OBJ_NULL) { - #if MICROPY_PY_USOCKET_EXTENDED_STATE + #if MICROPY_PY_SOCKET_EXTENDED_STATE // store the timeout in the socket state until a NIC is bound self->timeout = timeout; #else @@ -655,4 +655,4 @@ const mp_obj_module_t mp_module_socket = { MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); -#endif // MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP +#endif // MICROPY_PY_NETWORK && MICROPY_PY_SOCKET && !MICROPY_PY_LWIP diff --git a/extmod/modussl_axtls.c b/extmod/modussl_axtls.c index c09059cae85..1c9caf76ebf 100644 --- a/extmod/modussl_axtls.c +++ b/extmod/modussl_axtls.c @@ -31,7 +31,7 @@ #include "py/stream.h" #include "py/objstr.h" -#if MICROPY_PY_USSL && MICROPY_SSL_AXTLS +#if MICROPY_PY_SSL && MICROPY_SSL_AXTLS #include "ssl.h" @@ -118,7 +118,7 @@ STATIC NORETURN void ssl_raise_error(int err) { STATIC mp_obj_ssl_socket_t *ssl_socket_new(mp_obj_t sock, struct ssl_args *args) { - #if MICROPY_PY_USSL_FINALISER + #if MICROPY_PY_SSL_FINALISER mp_obj_ssl_socket_t *o = m_new_obj_with_finaliser(mp_obj_ssl_socket_t); #else mp_obj_ssl_socket_t *o = m_new_obj(mp_obj_ssl_socket_t); @@ -301,7 +301,7 @@ STATIC const mp_rom_map_elem_t ssl_socket_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&ssl_socket_setblocking_obj) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) }, - #if MICROPY_PY_USSL_FINALISER + #if MICROPY_PY_SSL_FINALISER { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_stream_close_obj) }, #endif }; @@ -359,4 +359,4 @@ const mp_obj_module_t mp_module_ssl = { MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl); -#endif // MICROPY_PY_USSL && MICROPY_SSL_AXTLS +#endif // MICROPY_PY_SSL && MICROPY_SSL_AXTLS diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c index dbe802f75b1..d724e0a08a5 100644 --- a/extmod/modussl_mbedtls.c +++ b/extmod/modussl_mbedtls.c @@ -26,7 +26,7 @@ */ #include "py/mpconfig.h" -#if MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS +#if MICROPY_PY_SSL && MICROPY_SSL_MBEDTLS #include #include @@ -163,7 +163,7 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) { // Verify the socket object has the full stream protocol mp_get_stream_raise(sock, MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); - #if MICROPY_PY_USSL_FINALISER + #if MICROPY_PY_SSL_FINALISER mp_obj_ssl_socket_t *o = m_new_obj_with_finaliser(mp_obj_ssl_socket_t); #else mp_obj_ssl_socket_t *o = m_new_obj(mp_obj_ssl_socket_t); @@ -442,7 +442,7 @@ STATIC const mp_rom_map_elem_t ssl_socket_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) }, { MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socket_setblocking_obj) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) }, - #if MICROPY_PY_USSL_FINALISER + #if MICROPY_PY_SSL_FINALISER { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_stream_close_obj) }, #endif #if MICROPY_UNIX_COVERAGE @@ -509,4 +509,4 @@ const mp_obj_module_t mp_module_ssl = { MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl); -#endif // MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS +#endif // MICROPY_PY_SSL && MICROPY_SSL_MBEDTLS diff --git a/extmod/modutime.c b/extmod/modutime.c index 9731f5ff0b2..1dfd7aa2c09 100644 --- a/extmod/modutime.c +++ b/extmod/modutime.c @@ -30,13 +30,13 @@ #include "py/smallint.h" #include "extmod/modutime.h" -#if MICROPY_PY_UTIME +#if MICROPY_PY_TIME -#ifdef MICROPY_PY_UTIME_INCLUDEFILE -#include MICROPY_PY_UTIME_INCLUDEFILE +#ifdef MICROPY_PY_TIME_INCLUDEFILE +#include MICROPY_PY_TIME_INCLUDEFILE #endif -#if MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME +#if MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME #include "shared/timeutils/timeutils.h" @@ -96,9 +96,9 @@ STATIC mp_obj_t time_mktime(mp_obj_t tuple) { } MP_DEFINE_CONST_FUN_OBJ_1(mp_time_mktime_obj, time_mktime); -#endif // MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME +#endif // MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME -#if MICROPY_PY_UTIME_TIME_TIME_NS +#if MICROPY_PY_TIME_TIME_TIME_NS // time() // Return the number of seconds since the Epoch. @@ -114,10 +114,10 @@ STATIC mp_obj_t time_time_ns(void) { } MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_ns_obj, time_time_ns); -#endif // MICROPY_PY_UTIME_TIME_TIME_NS +#endif // MICROPY_PY_TIME_TIME_TIME_NS STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { - #ifdef MICROPY_PY_UTIME_CUSTOM_SLEEP + #ifdef MICROPY_PY_TIME_CUSTOM_SLEEP mp_time_sleep(seconds_o); #else #if MICROPY_PY_BUILTINS_FLOAT @@ -149,17 +149,17 @@ STATIC mp_obj_t time_sleep_us(mp_obj_t arg) { MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_us_obj, time_sleep_us); STATIC mp_obj_t time_ticks_ms(void) { - return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); + return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_TIME_TICKS_PERIOD - 1)); } MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_ms_obj, time_ticks_ms); STATIC mp_obj_t time_ticks_us(void) { - return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_us() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); + return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_us() & (MICROPY_PY_TIME_TICKS_PERIOD - 1)); } MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_us_obj, time_ticks_us); STATIC mp_obj_t time_ticks_cpu(void) { - return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_cpu() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); + return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_cpu() & (MICROPY_PY_TIME_TICKS_PERIOD - 1)); } MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_cpu_obj, time_ticks_cpu); @@ -169,8 +169,8 @@ STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) { mp_uint_t end = MP_OBJ_SMALL_INT_VALUE(end_in); // Optimized formula avoiding if conditions. We adjust difference "forward", // wrap it around and adjust back. - mp_int_t diff = ((end - start + MICROPY_PY_UTIME_TICKS_PERIOD / 2) & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)) - - MICROPY_PY_UTIME_TICKS_PERIOD / 2; + mp_int_t diff = ((end - start + MICROPY_PY_TIME_TICKS_PERIOD / 2) & (MICROPY_PY_TIME_TICKS_PERIOD - 1)) + - MICROPY_PY_TIME_TICKS_PERIOD / 2; return MP_OBJ_NEW_SMALL_INT(diff); } MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_diff_obj, time_ticks_diff); @@ -188,24 +188,24 @@ STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) { // // This unsigned comparison is equivalent to a signed comparison of: // delta <= -TICKS_PERIOD/2 || delta >= TICKS_PERIOD/2 - if (delta + MICROPY_PY_UTIME_TICKS_PERIOD / 2 - 1 >= MICROPY_PY_UTIME_TICKS_PERIOD - 1) { + if (delta + MICROPY_PY_TIME_TICKS_PERIOD / 2 - 1 >= MICROPY_PY_TIME_TICKS_PERIOD - 1) { mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("ticks interval overflow")); } - return MP_OBJ_NEW_SMALL_INT((ticks + delta) & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); + return MP_OBJ_NEW_SMALL_INT((ticks + delta) & (MICROPY_PY_TIME_TICKS_PERIOD - 1)); } MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_add_obj, time_ticks_add); STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) }, - #if MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME + #if MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME { MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&mp_time_localtime_obj) }, { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&mp_time_localtime_obj) }, { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&mp_time_mktime_obj) }, #endif - #if MICROPY_PY_UTIME_TIME_TIME_NS + #if MICROPY_PY_TIME_TIME_TIME_NS { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mp_time_time_obj) }, { MP_ROM_QSTR(MP_QSTR_time_ns), MP_ROM_PTR(&mp_time_time_ns_obj) }, #endif @@ -220,8 +220,8 @@ STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_time_ticks_add_obj) }, { MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_time_ticks_diff_obj) }, - #ifdef MICROPY_PY_UTIME_EXTRA_GLOBALS - MICROPY_PY_UTIME_EXTRA_GLOBALS + #ifdef MICROPY_PY_TIME_EXTRA_GLOBALS + MICROPY_PY_TIME_EXTRA_GLOBALS #endif }; STATIC MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table); @@ -233,4 +233,4 @@ const mp_obj_module_t mp_module_time = { MP_REGISTER_MODULE(MP_QSTR_time, mp_module_time); -#endif // MICROPY_PY_UTIME +#endif // MICROPY_PY_TIME diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c index 643aef5d6d3..7c037ea0a90 100644 --- a/extmod/modutimeq.c +++ b/extmod/modutimeq.c @@ -31,9 +31,9 @@ #include "py/runtime.h" #include "py/smallint.h" -#if MICROPY_PY_UTIMEQ +#if MICROPY_PY_TIMEQ -#define MODULO MICROPY_PY_UTIME_TICKS_PERIOD +#define MODULO MICROPY_PY_TIME_TICKS_PERIOD #define DEBUG 0 @@ -232,4 +232,4 @@ const mp_obj_module_t mp_module_timeq = { MP_REGISTER_MODULE(MP_QSTR_timeq, mp_module_timeq); -#endif // MICROPY_PY_UTIMEQ +#endif // MICROPY_PY_TIMEQ diff --git a/extmod/moduwebsocket.c b/extmod/moduwebsocket.c index 76330f31259..ac90dea8b36 100644 --- a/extmod/moduwebsocket.c +++ b/extmod/moduwebsocket.c @@ -32,7 +32,7 @@ #include "py/stream.h" #include "extmod/moduwebsocket.h" -#if MICROPY_PY_UWEBSOCKET +#if MICROPY_PY_WEBSOCKET enum { FRAME_HEADER, FRAME_OPT, PAYLOAD, CONTROL }; @@ -313,4 +313,4 @@ const mp_obj_module_t mp_module_websocket = { MP_REGISTER_MODULE(MP_QSTR_websocket, mp_module_websocket); -#endif // MICROPY_PY_UWEBSOCKET +#endif // MICROPY_PY_WEBSOCKET diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index e840bdcbfd5..a912f113ce4 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -31,7 +31,7 @@ #include "py/stream.h" #include "py/mperrno.h" -#if MICROPY_PY_UZLIB +#if MICROPY_PY_ZLIB #include "lib/uzlib/tinf.h" @@ -236,4 +236,4 @@ MP_REGISTER_MODULE(MP_QSTR_zlib, mp_module_zlib); #include "lib/uzlib/adler32.c" #include "lib/uzlib/crc32.c" -#endif // MICROPY_PY_UZLIB +#endif // MICROPY_PY_ZLIB diff --git a/extmod/uos_dupterm.c b/extmod/uos_dupterm.c index c72b365bea0..cfd1c626164 100644 --- a/extmod/uos_dupterm.c +++ b/extmod/uos_dupterm.c @@ -66,7 +66,7 @@ uintptr_t mp_os_dupterm_poll(uintptr_t poll_flags) { int errcode = 0; mp_uint_t ret = 0; const mp_stream_p_t *stream_p = mp_get_stream(s); - #if MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM + #if MICROPY_PY_OS_DUPTERM_BUILTIN_STREAM if (mp_os_dupterm_is_builtin_stream(s)) { ret = stream_p->ioctl(s, MP_STREAM_POLL, poll_flags, &errcode); } else @@ -99,7 +99,7 @@ int mp_os_dupterm_rx_chr(void) { continue; } - #if MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM + #if MICROPY_PY_OS_DUPTERM_BUILTIN_STREAM if (mp_os_dupterm_is_builtin_stream(MP_STATE_VM(dupterm_objs[idx]))) { byte buf[1]; int errcode = 0; @@ -154,7 +154,7 @@ void mp_os_dupterm_tx_strn(const char *str, size_t len) { continue; } - #if MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM + #if MICROPY_PY_OS_DUPTERM_BUILTIN_STREAM if (mp_os_dupterm_is_builtin_stream(MP_STATE_VM(dupterm_objs[idx]))) { int errcode = 0; const mp_stream_p_t *stream_p = mp_get_stream(MP_STATE_VM(dupterm_objs[idx])); @@ -194,7 +194,7 @@ STATIC mp_obj_t mp_os_dupterm(size_t n_args, const mp_obj_t *args) { MP_STATE_VM(dupterm_objs[idx]) = args[0]; } - #if MICROPY_PY_UOS_DUPTERM_STREAM_DETACHED_ATTACHED + #if MICROPY_PY_OS_DUPTERM_STREAM_DETACHED_ATTACHED mp_os_dupterm_stream_detached_attached(previous_obj, args[0]); #endif diff --git a/extmod/vfs_posix.c b/extmod/vfs_posix.c index 9b856e1f01c..d63bb5be7bf 100644 --- a/extmod/vfs_posix.c +++ b/extmod/vfs_posix.c @@ -332,7 +332,7 @@ STATIC mp_obj_t vfs_posix_stat(mp_obj_t self_in, mp_obj_t path_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(vfs_posix_stat_obj, vfs_posix_stat); -#if MICROPY_PY_UOS_STATVFS +#if MICROPY_PY_OS_STATVFS #ifdef __ANDROID__ #define USE_STATFS 1 @@ -390,7 +390,7 @@ STATIC const mp_rom_map_elem_t vfs_posix_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_rename), MP_ROM_PTR(&vfs_posix_rename_obj) }, { MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&vfs_posix_rmdir_obj) }, { MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&vfs_posix_stat_obj) }, - #if MICROPY_PY_UOS_STATVFS + #if MICROPY_PY_OS_STATVFS { MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&vfs_posix_statvfs_obj) }, #endif }; diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index ea19de7fd04..1d89e3ca097 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -194,7 +194,7 @@ STATIC mp_uint_t vfs_posix_file_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_ return 0; case MP_STREAM_GET_FILENO: return o->fd; - #if MICROPY_PY_USELECT + #if MICROPY_PY_SELECT case MP_STREAM_POLL: { #ifdef _WIN32 mp_raise_NotImplementedError(MP_ERROR_TEXT("poll on file not available on win32")); diff --git a/ports/cc3200/mods/modusocket.c b/ports/cc3200/mods/modusocket.c index da756296fc9..9b614c6d34c 100644 --- a/ports/cc3200/mods/modusocket.c +++ b/ports/cc3200/mods/modusocket.c @@ -489,7 +489,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind); STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) { mod_network_socket_obj_t *self = args[0]; - int32_t backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT; + int32_t backlog = MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT; if (n_args > 1) { backlog = mp_obj_get_int(args[1]); backlog = (backlog < 0) ? 0 : backlog; diff --git a/ports/cc3200/mpconfigport.h b/ports/cc3200/mpconfigport.h index 8026f7b7575..af10c63531f 100644 --- a/ports/cc3200/mpconfigport.h +++ b/ports/cc3200/mpconfigport.h @@ -104,29 +104,29 @@ #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_CMATH (0) #define MICROPY_PY_IO (1) -#define MICROPY_PY_UERRNO (1) -#define MICROPY_PY_UERRNO_ERRORCODE (0) +#define MICROPY_PY_ERRNO (1) +#define MICROPY_PY_ERRNO_ERRORCODE (0) #define MICROPY_PY_THREAD (1) #define MICROPY_PY_THREAD_GIL (1) -#define MICROPY_PY_UBINASCII (1) +#define MICROPY_PY_BINASCII (1) #define MICROPY_PY_UCTYPES (0) -#define MICROPY_PY_UZLIB (0) -#define MICROPY_PY_UJSON (1) -#define MICROPY_PY_URE (1) -#define MICROPY_PY_UHEAPQ (0) -#define MICROPY_PY_UHASHLIB (0) -#define MICROPY_PY_USELECT (1) -#define MICROPY_PY_UTIME (1) -#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/cc3200/mods/modutime.c" +#define MICROPY_PY_ZLIB (0) +#define MICROPY_PY_JSON (1) +#define MICROPY_PY_RE (1) +#define MICROPY_PY_HEAPQ (0) +#define MICROPY_PY_HASHLIB (0) +#define MICROPY_PY_SELECT (1) +#define MICROPY_PY_TIME (1) +#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/cc3200/mods/modtime.c" #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1) #define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) #define MICROPY_KBD_EXCEPTION (1) // We define our own list of errno constants to include in errno module -#define MICROPY_PY_UERRNO_LIST \ +#define MICROPY_PY_ERRNO_LIST \ X(EPERM) \ X(EIO) \ X(ENODEV) \ diff --git a/ports/esp32/main.c b/ports/esp32/main.c index b3d467a80e9..3e7c9ee162d 100644 --- a/ports/esp32/main.c +++ b/ports/esp32/main.c @@ -224,7 +224,7 @@ void mp_task(void *pvParameter) { // TODO: machine_rmt_deinit_all(); machine_pins_deinit(); machine_deinit(); - #if MICROPY_PY_USOCKET_EVENTS + #if MICROPY_PY_SOCKET_EVENTS socket_events_deinit(); #endif diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index 114629a9d77..0b2d40e333c 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -73,7 +73,7 @@ typedef struct _socket_obj_t { uint8_t proto; uint8_t state; unsigned int retries; - #if MICROPY_PY_USOCKET_EVENTS + #if MICROPY_PY_SOCKET_EVENTS mp_obj_t events_callback; struct _socket_obj_t *events_next; #endif @@ -81,7 +81,7 @@ typedef struct _socket_obj_t { void _socket_settimeout(socket_obj_t *sock, uint64_t timeout_ms); -#if MICROPY_PY_USOCKET_EVENTS +#if MICROPY_PY_SOCKET_EVENTS // Support for callbacks on asynchronous socket events (when socket becomes readable) // This divisor is used to reduce the load on the system, so it doesn't poll sockets too often @@ -144,7 +144,7 @@ void socket_events_handler(void) { } } -#endif // MICROPY_PY_USOCKET_EVENTS +#endif // MICROPY_PY_SOCKET_EVENTS static inline void check_for_exceptions(void) { mp_handle_pending(true); @@ -299,7 +299,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind); STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) { socket_obj_t *self = MP_OBJ_TO_PTR(args[0]); - int backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT; + int backlog = MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT; if (n_args > 1) { backlog = mp_obj_get_int(args[1]); backlog = (backlog < 0) ? 0 : backlog; @@ -396,7 +396,7 @@ STATIC mp_obj_t socket_setsockopt(size_t n_args, const mp_obj_t *args) { break; } - #if MICROPY_PY_USOCKET_EVENTS + #if MICROPY_PY_SOCKET_EVENTS // level: SOL_SOCKET // special "register callback" option case 20: { @@ -734,7 +734,7 @@ STATIC mp_uint_t socket_stream_ioctl(mp_obj_t self_in, mp_uint_t request, uintpt return ret; } else if (request == MP_STREAM_CLOSE) { if (socket->fd >= 0) { - #if MICROPY_PY_USOCKET_EVENTS + #if MICROPY_PY_SOCKET_EVENTS if (socket->events_callback != MP_OBJ_NULL) { socket_events_remove(socket); socket->events_callback = MP_OBJ_NULL; @@ -869,7 +869,7 @@ const mp_obj_module_t mp_module_socket = { .globals = (mp_obj_dict_t *)&mp_module_socket_globals, }; -// Note: This port doesn't define MICROPY_PY_USOCKET or MICROPY_PY_LWIP so +// Note: This port doesn't define MICROPY_PY_SOCKET or MICROPY_PY_LWIP so // this will not conflict with the common implementation provided by // extmod/mod{lwip,socket}.c. MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); diff --git a/ports/esp32/moduos.c b/ports/esp32/moduos.c index 6a5a26c256b..287f1d99002 100644 --- a/ports/esp32/moduos.c +++ b/ports/esp32/moduos.c @@ -49,7 +49,7 @@ STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); -#if MICROPY_PY_UOS_DUPTERM_NOTIFY +#if MICROPY_PY_OS_DUPTERM_NOTIFY STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) { (void)obj_in; for (;;) { diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index d6aaa987872..d25a5c2734d 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -62,9 +62,9 @@ #define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (1) #define MICROPY_PY_BUILTINS_HELP_TEXT esp32_help_text #define MICROPY_PY_IO_BUFFEREDWRITER (1) -#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/esp32/modutime.c" +#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/esp32/modtime.c" #define MICROPY_PY_THREAD (1) #define MICROPY_PY_THREAD_GIL (1) #define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32) @@ -83,17 +83,17 @@ #define MICROPY_BLUETOOTH_NIMBLE (1) #define MICROPY_BLUETOOTH_NIMBLE_BINDINGS_ONLY (1) #endif -#define MICROPY_PY_UTIMEQ (1) -#define MICROPY_PY_UHASHLIB_SHA1 (1) -#define MICROPY_PY_UHASHLIB_SHA256 (1) -#define MICROPY_PY_UCRYPTOLIB (1) -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (esp_random()) -#define MICROPY_PY_UOS_INCLUDEFILE "ports/esp32/moduos.c" +#define MICROPY_PY_TIMEQ (1) +#define MICROPY_PY_HASHLIB_SHA1 (1) +#define MICROPY_PY_HASHLIB_SHA256 (1) +#define MICROPY_PY_CRYPTOLIB (1) +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (esp_random()) +#define MICROPY_PY_OS_INCLUDEFILE "ports/esp32/moduos.c" #define MICROPY_PY_OS_DUPTERM (1) -#define MICROPY_PY_UOS_DUPTERM_NOTIFY (1) -#define MICROPY_PY_UOS_SYNC (1) -#define MICROPY_PY_UOS_UNAME (1) -#define MICROPY_PY_UOS_URANDOM (1) +#define MICROPY_PY_OS_DUPTERM_NOTIFY (1) +#define MICROPY_PY_OS_SYNC (1) +#define MICROPY_PY_OS_UNAME (1) +#define MICROPY_PY_OS_URANDOM (1) #define MICROPY_PY_MACHINE (1) #define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new #define MICROPY_PY_MACHINE_BITSTREAM (1) @@ -136,14 +136,14 @@ #endif #define MICROPY_HW_SOFTSPI_MIN_DELAY (0) #define MICROPY_HW_SOFTSPI_MAX_BAUDRATE (ets_get_cpu_frequency() * 1000000 / 200) // roughly -#define MICROPY_PY_USSL (1) +#define MICROPY_PY_SSL (1) #define MICROPY_SSL_MBEDTLS (1) -#define MICROPY_PY_USSL_FINALISER (1) -#define MICROPY_PY_UWEBSOCKET (1) +#define MICROPY_PY_SSL_FINALISER (1) +#define MICROPY_PY_WEBSOCKET (1) #define MICROPY_PY_WEBREPL (1) #define MICROPY_PY_ONEWIRE (1) -#define MICROPY_PY_UPLATFORM (1) -#define MICROPY_PY_USOCKET_EVENTS (MICROPY_PY_WEBREPL) +#define MICROPY_PY_PLATFORM (1) +#define MICROPY_PY_SOCKET_EVENTS (MICROPY_PY_WEBREPL) #define MICROPY_PY_BLUETOOTH_RANDOM_ADDR (1) #define MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME ("ESP32") @@ -169,10 +169,10 @@ void *esp_native_code_commit(void *, size_t, void *); #define MICROPY_BEGIN_ATOMIC_SECTION() portENTER_CRITICAL_NESTED() #define MICROPY_END_ATOMIC_SECTION(state) portEXIT_CRITICAL_NESTED(state) -#if MICROPY_PY_USOCKET_EVENTS -#define MICROPY_PY_USOCKET_EVENTS_HANDLER extern void socket_events_handler(void); socket_events_handler(); +#if MICROPY_PY_SOCKET_EVENTS +#define MICROPY_PY_SOCKET_EVENTS_HANDLER extern void socket_events_handler(void); socket_events_handler(); #else -#define MICROPY_PY_USOCKET_EVENTS_HANDLER +#define MICROPY_PY_SOCKET_EVENTS_HANDLER #endif #if MICROPY_PY_THREAD @@ -180,7 +180,7 @@ void *esp_native_code_commit(void *, size_t, void *); do { \ extern void mp_handle_pending(bool); \ mp_handle_pending(true); \ - MICROPY_PY_USOCKET_EVENTS_HANDLER \ + MICROPY_PY_SOCKET_EVENTS_HANDLER \ MP_THREAD_GIL_EXIT(); \ ulTaskNotifyTake(pdFALSE, 1); \ MP_THREAD_GIL_ENTER(); \ @@ -190,7 +190,7 @@ void *esp_native_code_commit(void *, size_t, void *); do { \ extern void mp_handle_pending(bool); \ mp_handle_pending(true); \ - MICROPY_PY_USOCKET_EVENTS_HANDLER \ + MICROPY_PY_SOCKET_EVENTS_HANDLER \ asm ("waiti 0"); \ } while (0); #endif diff --git a/ports/esp32/mphalport.c b/ports/esp32/mphalport.c index 61e9fd563ef..4c8fa012f4f 100644 --- a/ports/esp32/mphalport.c +++ b/ports/esp32/mphalport.c @@ -138,7 +138,7 @@ void mp_hal_delay_ms(uint32_t ms) { uint64_t t0 = esp_timer_get_time(); for (;;) { mp_handle_pending(true); - MICROPY_PY_USOCKET_EVENTS_HANDLER + MICROPY_PY_SOCKET_EVENTS_HANDLER MP_THREAD_GIL_EXIT(); uint64_t t1 = esp_timer_get_time(); dt = t1 - t0; diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index e3727dfeda4..e4db811f240 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -27,7 +27,7 @@ QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h # MicroPython feature configurations MICROPY_ROM_TEXT_COMPRESSION ?= 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_AXTLS = 1 AXTLS_DEFS_EXTRA = -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=4096 BTREE_DEFS_EXTRA = -DDEFPSIZE=1024 -DMINCACHE=3 diff --git a/ports/esp8266/boards/GENERIC/mpconfigboard.h b/ports/esp8266/boards/GENERIC/mpconfigboard.h index 1d9b8e6f70d..52c93f83a36 100644 --- a/ports/esp8266/boards/GENERIC/mpconfigboard.h +++ b/ports/esp8266/boards/GENERIC/mpconfigboard.h @@ -11,4 +11,4 @@ #define MICROPY_READER_VFS (MICROPY_VFS) #define MICROPY_VFS (1) -#define MICROPY_PY_UCRYPTOLIB (1) +#define MICROPY_PY_CRYPTOLIB (1) diff --git a/ports/esp8266/boards/GENERIC_1M/mpconfigboard.h b/ports/esp8266/boards/GENERIC_1M/mpconfigboard.h index cf5127686cc..f811f70592f 100644 --- a/ports/esp8266/boards/GENERIC_1M/mpconfigboard.h +++ b/ports/esp8266/boards/GENERIC_1M/mpconfigboard.h @@ -14,4 +14,4 @@ #define MICROPY_PY_FSTRINGS (0) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) #define MICROPY_PY_UASYNCIO (0) -#define MICROPY_PY_UCRYPTOLIB (1) +#define MICROPY_PY_CRYPTOLIB (1) diff --git a/ports/esp8266/boards/GENERIC_512K/mpconfigboard.h b/ports/esp8266/boards/GENERIC_512K/mpconfigboard.h index b0adb7081c9..fc933cd3eb4 100644 --- a/ports/esp8266/boards/GENERIC_512K/mpconfigboard.h +++ b/ports/esp8266/boards/GENERIC_512K/mpconfigboard.h @@ -9,5 +9,5 @@ #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) #define MICROPY_PY_SYS_STDIO_BUFFER (0) #define MICROPY_PY_UASYNCIO (0) -#define MICROPY_PY_URE_SUB (0) +#define MICROPY_PY_RE_SUB (0) #define MICROPY_PY_FRAMEBUF (0) diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h index 0cfb83f73e7..9985d59dd39 100644 --- a/ports/esp8266/mpconfigport.h +++ b/ports/esp8266/mpconfigport.h @@ -36,8 +36,8 @@ #define MICROPY_PY_MATH_FACTORIAL (0) #define MICROPY_PY_MATH_ISCLOSE (0) #define MICROPY_PY_SYS_PS1_PS2 (0) -#define MICROPY_PY_UBINASCII_CRC32 (0) -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) +#define MICROPY_PY_BINASCII_CRC32 (0) +#define MICROPY_PY_RANDOM_EXTRA_FUNCS (0) // Configure other options. #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C) @@ -54,11 +54,11 @@ #define MICROPY_REPL_EVENT_DRIVEN (0) #define MICROPY_USE_INTERNAL_ERRNO (1) #define MICROPY_PY_BUILTINS_HELP_TEXT esp_help_text -#define MICROPY_PY_UHASHLIB_SHA1 (MICROPY_PY_USSL && MICROPY_SSL_AXTLS) -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (*WDEV_HWRNG) -#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/esp8266/modutime.c" +#define MICROPY_PY_HASHLIB_SHA1 (MICROPY_PY_SSL && MICROPY_SSL_AXTLS) +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (*WDEV_HWRNG) +#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/esp8266/modutime.c" #define MICROPY_PY_LWIP (1) #define MICROPY_PY_LWIP_SOCK_RAW (1) #define MICROPY_PY_MACHINE (1) @@ -78,19 +78,19 @@ #endif #define MICROPY_PY_NETWORK_INCLUDEFILE "ports/esp8266/modnetwork.h" #define MICROPY_PY_NETWORK_MODULE_GLOBALS_INCLUDEFILE "ports/esp8266/modnetwork_globals.h" -#define MICROPY_PY_UWEBSOCKET (1) +#define MICROPY_PY_WEBSOCKET (1) #define MICROPY_PY_ONEWIRE (1) #define MICROPY_PY_WEBREPL (1) #define MICROPY_PY_WEBREPL_DELAY (20) #define MICROPY_PY_WEBREPL_STATIC_FILEBUF (1) -#define MICROPY_PY_UOS_INCLUDEFILE "ports/esp8266/moduos.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/esp8266/modos.c" #define MICROPY_PY_OS_DUPTERM (2) -#define MICROPY_PY_UOS_DUPTERM_NOTIFY (1) -#define MICROPY_PY_UOS_DUPTERM_STREAM_DETACHED_ATTACHED (1) -#define MICROPY_PY_UOS_SYNC (1) -#define MICROPY_PY_UOS_UNAME (1) -#define MICROPY_PY_UOS_UNAME_RELEASE_DYNAMIC (1) -#define MICROPY_PY_UOS_URANDOM (1) +#define MICROPY_PY_OS_DUPTERM_NOTIFY (1) +#define MICROPY_PY_OS_DUPTERM_STREAM_DETACHED_ATTACHED (1) +#define MICROPY_PY_OS_SYNC (1) +#define MICROPY_PY_OS_UNAME (1) +#define MICROPY_PY_OS_UNAME_RELEASE_DYNAMIC (1) +#define MICROPY_PY_OS_URANDOM (1) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_WARNINGS (1) diff --git a/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.mk b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.mk index 8617261d540..236db27c87d 100644 --- a/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.mk +++ b/ports/mimxrt/boards/ADAFRUIT_METRO_M7/mpconfigboard.mk @@ -7,5 +7,5 @@ MICROPY_HW_FLASH_TYPE ?= qspi_nor_flash MICROPY_HW_FLASH_SIZE ?= 0x800000 # 8MB MICROPY_PY_NETWORK_NINAW10 ?= 1 -MICROPY_PY_USSL ?= 1 +MICROPY_PY_SSL ?= 1 MICROPY_SSL_MBEDTLS ?= 1 diff --git a/ports/mimxrt/boards/MIMXRT1020_EVK/mpconfigboard.mk b/ports/mimxrt/boards/MIMXRT1020_EVK/mpconfigboard.mk index 85bc1f71b60..547b88d57de 100644 --- a/ports/mimxrt/boards/MIMXRT1020_EVK/mpconfigboard.mk +++ b/ports/mimxrt/boards/MIMXRT1020_EVK/mpconfigboard.mk @@ -10,7 +10,7 @@ MICROPY_HW_SDRAM_AVAIL = 1 MICROPY_HW_SDRAM_SIZE = 0x2000000 # 32MB MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py diff --git a/ports/mimxrt/boards/MIMXRT1050_EVK/mpconfigboard.mk b/ports/mimxrt/boards/MIMXRT1050_EVK/mpconfigboard.mk index 8e4213569a4..0cf2a348046 100644 --- a/ports/mimxrt/boards/MIMXRT1050_EVK/mpconfigboard.mk +++ b/ports/mimxrt/boards/MIMXRT1050_EVK/mpconfigboard.mk @@ -10,7 +10,7 @@ MICROPY_HW_SDRAM_AVAIL = 1 MICROPY_HW_SDRAM_SIZE = 0x2000000 # 32MB MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py diff --git a/ports/mimxrt/boards/MIMXRT1060_EVK/mpconfigboard.mk b/ports/mimxrt/boards/MIMXRT1060_EVK/mpconfigboard.mk index 22cd5356d93..c2556a27248 100644 --- a/ports/mimxrt/boards/MIMXRT1060_EVK/mpconfigboard.mk +++ b/ports/mimxrt/boards/MIMXRT1060_EVK/mpconfigboard.mk @@ -10,7 +10,7 @@ MICROPY_HW_SDRAM_AVAIL = 1 MICROPY_HW_SDRAM_SIZE = 0x2000000 # 32MB MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py diff --git a/ports/mimxrt/boards/MIMXRT1064_EVK/mpconfigboard.mk b/ports/mimxrt/boards/MIMXRT1064_EVK/mpconfigboard.mk index b0bd7ec6ace..d3ba752419e 100644 --- a/ports/mimxrt/boards/MIMXRT1064_EVK/mpconfigboard.mk +++ b/ports/mimxrt/boards/MIMXRT1064_EVK/mpconfigboard.mk @@ -10,7 +10,7 @@ MICROPY_HW_SDRAM_AVAIL = 1 MICROPY_HW_SDRAM_SIZE = 0x2000000 # 32MB MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py diff --git a/ports/mimxrt/boards/MIMXRT1170_EVK/mpconfigboard.mk b/ports/mimxrt/boards/MIMXRT1170_EVK/mpconfigboard.mk index dc44b93bd07..25747a52c6b 100644 --- a/ports/mimxrt/boards/MIMXRT1170_EVK/mpconfigboard.mk +++ b/ports/mimxrt/boards/MIMXRT1170_EVK/mpconfigboard.mk @@ -12,7 +12,7 @@ MICROPY_HW_SDRAM_AVAIL = 1 MICROPY_HW_SDRAM_SIZE = 0x4000000 # 64MB MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py diff --git a/ports/mimxrt/boards/OLIMEX_RT1010/mpconfigboard.h b/ports/mimxrt/boards/OLIMEX_RT1010/mpconfigboard.h index d63c0dc4039..3d080ff25f1 100644 --- a/ports/mimxrt/boards/OLIMEX_RT1010/mpconfigboard.h +++ b/ports/mimxrt/boards/OLIMEX_RT1010/mpconfigboard.h @@ -3,7 +3,7 @@ #define MICROPY_HW_USB_MANUFACTURER_STRING "Olimex Ltd." #define MICROPY_HW_USB_VID 0x15ba #define MICROPY_HW_USB_PID 0x0046 -#define MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM (0) +#define MICROPY_PY_OS_DUPTERM_BUILTIN_STREAM (0) // Olimex RT1010-Py has 1 board LED #define MICROPY_HW_LED1_PIN (pin_GPIO_11) diff --git a/ports/mimxrt/boards/SEEED_ARCH_MIX/mpconfigboard.mk b/ports/mimxrt/boards/SEEED_ARCH_MIX/mpconfigboard.mk index 8e530ac5589..ca27dff55f3 100644 --- a/ports/mimxrt/boards/SEEED_ARCH_MIX/mpconfigboard.mk +++ b/ports/mimxrt/boards/SEEED_ARCH_MIX/mpconfigboard.mk @@ -10,7 +10,7 @@ MICROPY_HW_SDRAM_AVAIL = 1 MICROPY_HW_SDRAM_SIZE = 0x2000000 # 32MB MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py diff --git a/ports/mimxrt/boards/TEENSY41/mpconfigboard.mk b/ports/mimxrt/boards/TEENSY41/mpconfigboard.mk index ca7e10b5e4c..cf07144668e 100755 --- a/ports/mimxrt/boards/TEENSY41/mpconfigboard.mk +++ b/ports/mimxrt/boards/TEENSY41/mpconfigboard.mk @@ -8,7 +8,7 @@ MICROPY_HW_FLASH_SIZE = 0x800000 # 8MB MICROPY_HW_FLASH_RESERVED ?= 0x1000 # 4KB MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py diff --git a/ports/mimxrt/moduos.c b/ports/mimxrt/moduos.c index 8ae8019aaef..ecfc3712d78 100644 --- a/ports/mimxrt/moduos.c +++ b/ports/mimxrt/moduos.c @@ -95,7 +95,7 @@ uint32_t trng_random_u32(void) { return rngval; } -#if MICROPY_PY_UOS_URANDOM +#if MICROPY_PY_OS_URANDOM STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; @@ -109,7 +109,7 @@ STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); #endif -#if MICROPY_PY_UOS_DUPTERM_NOTIFY +#if MICROPY_PY_OS_DUPTERM_NOTIFY STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) { (void)obj_in; for (;;) { diff --git a/ports/mimxrt/mpconfigport.h b/ports/mimxrt/mpconfigport.h index 52301cf94b2..be086cb5521 100644 --- a/ports/mimxrt/mpconfigport.h +++ b/ports/mimxrt/mpconfigport.h @@ -69,17 +69,17 @@ uint32_t trng_random_u32(void); // Extended modules #define MICROPY_EPOCH_IS_1970 (1) -#define MICROPY_PY_USSL_FINALISER (MICROPY_PY_USSL) -#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/mimxrt/modutime.c" -#define MICROPY_PY_UOS_INCLUDEFILE "ports/mimxrt/moduos.c" +#define MICROPY_PY_SSL_FINALISER (MICROPY_PY_SSL) +#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/mimxrt/modutime.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/mimxrt/moduos.c" #define MICROPY_PY_OS_DUPTERM (3) -#define MICROPY_PY_UOS_DUPTERM_NOTIFY (1) -#define MICROPY_PY_UOS_SYNC (1) -#define MICROPY_PY_UOS_UNAME (1) -#define MICROPY_PY_UOS_URANDOM (1) -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (trng_random_u32()) +#define MICROPY_PY_OS_DUPTERM_NOTIFY (1) +#define MICROPY_PY_OS_SYNC (1) +#define MICROPY_PY_OS_UNAME (1) +#define MICROPY_PY_OS_URANDOM (1) +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (trng_random_u32()) #define MICROPY_PY_MACHINE (1) #define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new #define MICROPY_PY_MACHINE_BITSTREAM (1) @@ -96,7 +96,7 @@ uint32_t trng_random_u32(void); #define MICROPY_PY_MACHINE_TIMER (1) #define MICROPY_SOFT_TIMER_TICKS_MS systick_ms #define MICROPY_PY_ONEWIRE (1) -#define MICROPY_PY_UPLATFORM (1) +#define MICROPY_PY_PLATFORM (1) // fatfs configuration used in ffconf.h #define MICROPY_FATFS_ENABLE_LFN (1) @@ -107,16 +107,16 @@ uint32_t trng_random_u32(void); #ifndef MICROPY_PY_NETWORK #define MICROPY_PY_NETWORK (1) #endif -#ifndef MICROPY_PY_USOCKET -#define MICROPY_PY_USOCKET (1) +#ifndef MICROPY_PY_SOCKET +#define MICROPY_PY_SOCKET (1) #endif -#define MICROPY_PY_UWEBSOCKET (MICROPY_PY_LWIP) +#define MICROPY_PY_WEBSOCKET (MICROPY_PY_LWIP) #define MICROPY_PY_WEBREPL (MICROPY_PY_LWIP) #define MICROPY_PY_LWIP_SOCK_RAW (MICROPY_PY_LWIP) -#define MICROPY_PY_USSL_FINALISER (MICROPY_PY_USSL) -// #define MICROPY_PY_UHASHLIB_MD5 (MICROPY_PY_USSL) -#define MICROPY_PY_UHASHLIB_SHA1 (MICROPY_PY_USSL) -// #define MICROPY_PY_UCRYPTOLIB (MICROPY_PY_USSL) +#define MICROPY_PY_SSL_FINALISER (MICROPY_PY_SSL) +// #define MICROPY_PY_HASHLIB_MD5 (MICROPY_PY_SSL) +#define MICROPY_PY_HASHLIB_SHA1 (MICROPY_PY_SSL) +// #define MICROPY_PY_CRYPTOLIB (MICROPY_PY_SSL) // Prevent the "LWIP task" from running. #define MICROPY_PY_LWIP_ENTER MICROPY_PY_PENDSV_ENTER diff --git a/ports/nrf/boards/evk_nina_b3/mpconfigboard.h b/ports/nrf/boards/evk_nina_b3/mpconfigboard.h index eab232848bc..d4ce93a0aca 100644 --- a/ports/nrf/boards/evk_nina_b3/mpconfigboard.h +++ b/ports/nrf/boards/evk_nina_b3/mpconfigboard.h @@ -41,8 +41,8 @@ #define MICROPY_EMIT_INLINE_THUMB (1) // Enable optional modules -#define MICROPY_PY_UERRNO (1) -#define MICROPY_PY_UHASHLIB (1) +#define MICROPY_PY_ERRNO (1) +#define MICROPY_PY_HASHLIB (1) // Peripherals Config #define MICROPY_PY_MACHINE_UART (1) diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 0799000b908..3a311fe5d9a 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -80,8 +80,8 @@ #define MICROPY_PY_SYS_STDFILES (CORE_FEAT) #endif -#ifndef MICROPY_PY_UBINASCII -#define MICROPY_PY_UBINASCII (CORE_FEAT) +#ifndef MICROPY_PY_BINASCII +#define MICROPY_PY_BINASCII (CORE_FEAT) #endif #ifndef MICROPY_PY_NRF @@ -134,7 +134,7 @@ #endif // Use port specific os module rather than extmod variant. -#define MICROPY_PY_UOS (0) +#define MICROPY_PY_OS (0) #define MICROPY_STREAMS_NON_BLOCK (1) #define MICROPY_CAN_OVERRIDE_BUILTINS (1) @@ -155,9 +155,9 @@ #define MICROPY_MODULE_BUILTIN_INIT (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_SYS_MAXSIZE (1) -#define MICROPY_PY_URANDOM (1) -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) -#define MICROPY_PY_UTIME (1) +#define MICROPY_PY_RANDOM (1) +#define MICROPY_PY_RANDOM_EXTRA_FUNCS (1) +#define MICROPY_PY_TIME (1) #define MICROPY_PY_MACHINE (1) #define MICROPY_PY_MACHINE_PULSE (0) #define MICROPY_PY_MACHINE_SOFTI2C (MICROPY_PY_MACHINE_I2C) @@ -286,7 +286,7 @@ typedef unsigned int mp_uint_t; // must be pointer size typedef long mp_off_t; #if MICROPY_HW_ENABLE_RNG -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (rng_generate_random_word()) +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (rng_generate_random_word()) long unsigned int rng_generate_random_word(void); #endif diff --git a/ports/qemu-arm/mpconfigport.h b/ports/qemu-arm/mpconfigport.h index 972dce61b49..0eada5a529c 100644 --- a/ports/qemu-arm/mpconfigport.h +++ b/ports/qemu-arm/mpconfigport.h @@ -36,16 +36,16 @@ #define MICROPY_PY_SYS_EXIT (1) #define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_PLATFORM "qemu-arm" -#define MICROPY_PY_UERRNO (1) -#define MICROPY_PY_UBINASCII (1) -#define MICROPY_PY_URANDOM (1) +#define MICROPY_PY_ERRNO (1) +#define MICROPY_PY_BINASCII (1) +#define MICROPY_PY_RANDOM (1) #define MICROPY_PY_UCTYPES (1) -#define MICROPY_PY_UZLIB (1) -#define MICROPY_PY_UJSON (1) -#define MICROPY_PY_UOS (1) -#define MICROPY_PY_URE (1) -#define MICROPY_PY_UHEAPQ (1) -#define MICROPY_PY_UHASHLIB (1) +#define MICROPY_PY_ZLIB (1) +#define MICROPY_PY_JSON (1) +#define MICROPY_PY_OS (1) +#define MICROPY_PY_RE (1) +#define MICROPY_PY_HEAPQ (1) +#define MICROPY_PY_HASHLIB (1) #define MICROPY_PY_MACHINE (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_USE_INTERNAL_PRINTF (1) diff --git a/ports/renesas-ra/boards/EK_RA4M1/mpconfigboard.h b/ports/renesas-ra/boards/EK_RA4M1/mpconfigboard.h index cd699e51bda..4845c0c09eb 100644 --- a/ports/renesas-ra/boards/EK_RA4M1/mpconfigboard.h +++ b/ports/renesas-ra/boards/EK_RA4M1/mpconfigboard.h @@ -10,8 +10,8 @@ #define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_GENERATOR_PEND_THROW (0) #define MICROPY_PY_MATH (0) -#define MICROPY_PY_UHEAPQ (0) -#define MICROPY_PY_UTIMEQ (0) +#define MICROPY_PY_HEAPQ (0) +#define MICROPY_PY_TIMEQ (0) #define MICROPY_PY_THREAD (0) // peripheral config diff --git a/ports/renesas-ra/boards/EK_RA4W1/mpconfigboard.h b/ports/renesas-ra/boards/EK_RA4W1/mpconfigboard.h index 5fd2d1c6a34..d8d22ad72f7 100644 --- a/ports/renesas-ra/boards/EK_RA4W1/mpconfigboard.h +++ b/ports/renesas-ra/boards/EK_RA4W1/mpconfigboard.h @@ -10,8 +10,8 @@ #define MICROPY_PY_BUILTINS_COMPLEX (1) #define MICROPY_PY_GENERATOR_PEND_THROW (1) #define MICROPY_PY_MATH (1) -#define MICROPY_PY_UHEAPQ (1) -#define MICROPY_PY_UTIMEQ (1) +#define MICROPY_PY_HEAPQ (1) +#define MICROPY_PY_TIMEQ (1) #define MICROPY_PY_THREAD (0) // disable ARM_THUMB_FP using vldr due to RA has single float only // peripheral config diff --git a/ports/renesas-ra/boards/EK_RA6M1/mpconfigboard.h b/ports/renesas-ra/boards/EK_RA6M1/mpconfigboard.h index b6f76a062e5..d746dbdfc28 100644 --- a/ports/renesas-ra/boards/EK_RA6M1/mpconfigboard.h +++ b/ports/renesas-ra/boards/EK_RA6M1/mpconfigboard.h @@ -10,8 +10,8 @@ #define MICROPY_PY_BUILTINS_COMPLEX (1) #define MICROPY_PY_GENERATOR_PEND_THROW (1) #define MICROPY_PY_MATH (1) -#define MICROPY_PY_UHEAPQ (1) -#define MICROPY_PY_UTIMEQ (1) +#define MICROPY_PY_HEAPQ (1) +#define MICROPY_PY_TIMEQ (1) #define MICROPY_PY_THREAD (0) // disable ARM_THUMB_FP using vldr due to RA has single float only // peripheral config diff --git a/ports/renesas-ra/boards/EK_RA6M2/mpconfigboard.h b/ports/renesas-ra/boards/EK_RA6M2/mpconfigboard.h index 9e3c462eec6..b6ecfe6d494 100644 --- a/ports/renesas-ra/boards/EK_RA6M2/mpconfigboard.h +++ b/ports/renesas-ra/boards/EK_RA6M2/mpconfigboard.h @@ -10,8 +10,8 @@ #define MICROPY_PY_BUILTINS_COMPLEX (1) #define MICROPY_PY_GENERATOR_PEND_THROW (1) #define MICROPY_PY_MATH (1) -#define MICROPY_PY_UHEAPQ (1) -#define MICROPY_PY_UTIMEQ (1) +#define MICROPY_PY_HEAPQ (1) +#define MICROPY_PY_TIMEQ (1) #define MICROPY_PY_THREAD (0) // disable ARM_THUMB_FP using vldr due to RA has single float only // peripheral config diff --git a/ports/renesas-ra/boards/RA4M1_CLICKER/mpconfigboard.h b/ports/renesas-ra/boards/RA4M1_CLICKER/mpconfigboard.h index 7b8ccb1445b..3934dd264b4 100644 --- a/ports/renesas-ra/boards/RA4M1_CLICKER/mpconfigboard.h +++ b/ports/renesas-ra/boards/RA4M1_CLICKER/mpconfigboard.h @@ -10,8 +10,8 @@ #define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_GENERATOR_PEND_THROW (0) #define MICROPY_PY_MATH (0) -#define MICROPY_PY_UHEAPQ (0) -#define MICROPY_PY_UTIMEQ (0) +#define MICROPY_PY_HEAPQ (0) +#define MICROPY_PY_TIMEQ (0) #define MICROPY_PY_THREAD (0) // peripheral config diff --git a/ports/renesas-ra/mpconfigport.h b/ports/renesas-ra/mpconfigport.h index 42834c1fbc7..1886d31541a 100644 --- a/ports/renesas-ra/mpconfigport.h +++ b/ports/renesas-ra/mpconfigport.h @@ -91,19 +91,19 @@ #endif // extended modules -#define MICROPY_PY_UOS_INCLUDEFILE "ports/renesas-ra/moduos.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/renesas-ra/moduos.c" #define MICROPY_PY_OS_DUPTERM (3) -#define MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM (1) -#define MICROPY_PY_UOS_DUPTERM_STREAM_DETACHED_ATTACHED (1) -#define MICROPY_PY_UOS_SEP (1) -#define MICROPY_PY_UOS_SYNC (1) -#define MICROPY_PY_UOS_UNAME (1) -#define MICROPY_PY_UOS_URANDOM (MICROPY_HW_ENABLE_RNG) -#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/renesas-ra/modutime.c" -#ifndef MICROPY_PY_UTIMEQ -#define MICROPY_PY_UTIMEQ (1) +#define MICROPY_PY_OS_DUPTERM_BUILTIN_STREAM (1) +#define MICROPY_PY_OS_DUPTERM_STREAM_DETACHED_ATTACHED (1) +#define MICROPY_PY_OS_SEP (1) +#define MICROPY_PY_OS_SYNC (1) +#define MICROPY_PY_OS_UNAME (1) +#define MICROPY_PY_OS_URANDOM (MICROPY_HW_ENABLE_RNG) +#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/renesas-ra/modtime.c" +#ifndef MICROPY_PY_TIMEQ +#define MICROPY_PY_TIMEQ (1) #endif #ifndef MICROPY_PY_MACHINE #define MICROPY_PY_MACHINE (1) @@ -126,8 +126,8 @@ #ifndef MICROPY_PY_ONEWIRE #define MICROPY_PY_ONEWIRE (1) #endif -#ifndef MICROPY_PY_UPLATFORM -#define MICROPY_PY_UPLATFORM (1) +#ifndef MICROPY_PY_PLATFORM +#define MICROPY_PY_PLATFORM (1) #endif // fatfs configuration used in ffconf.h diff --git a/ports/rp2/boards/ARDUINO_NANO_RP2040_CONNECT/mpconfigboard.h b/ports/rp2/boards/ARDUINO_NANO_RP2040_CONNECT/mpconfigboard.h index a4fb8b7c8c9..98b9c0f6faa 100644 --- a/ports/rp2/boards/ARDUINO_NANO_RP2040_CONNECT/mpconfigboard.h +++ b/ports/rp2/boards/ARDUINO_NANO_RP2040_CONNECT/mpconfigboard.h @@ -8,7 +8,7 @@ #define MICROPY_PY_NETWORK (1) // Enable MD5 hash. -#define MICROPY_PY_UHASHLIB_MD5 (1) +#define MICROPY_PY_HASHLIB_MD5 (1) // Disable internal error numbers. #define MICROPY_USE_INTERNAL_ERRNO (0) diff --git a/ports/rp2/mpconfigport.h b/ports/rp2/mpconfigport.h index 720e858f196..de05a281bdb 100644 --- a/ports/rp2/mpconfigport.h +++ b/ports/rp2/mpconfigport.h @@ -95,21 +95,21 @@ // Extended modules #define MICROPY_EPOCH_IS_1970 (1) -#define MICROPY_PY_UOS_INCLUDEFILE "ports/rp2/moduos.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/rp2/moduos.c" #ifndef MICROPY_PY_OS_DUPTERM #define MICROPY_PY_OS_DUPTERM (1) #endif -#define MICROPY_PY_UOS_SYNC (1) -#define MICROPY_PY_UOS_UNAME (1) -#define MICROPY_PY_UOS_URANDOM (1) -#define MICROPY_PY_URE_MATCH_GROUPS (1) -#define MICROPY_PY_URE_MATCH_SPAN_START_END (1) -#define MICROPY_PY_UHASHLIB_SHA1 (1) -#define MICROPY_PY_UCRYPTOLIB (1) -#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/rp2/modutime.c" -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (rosc_random_u32()) +#define MICROPY_PY_OS_SYNC (1) +#define MICROPY_PY_OS_UNAME (1) +#define MICROPY_PY_OS_URANDOM (1) +#define MICROPY_PY_RE_MATCH_GROUPS (1) +#define MICROPY_PY_RE_MATCH_SPAN_START_END (1) +#define MICROPY_PY_HASHLIB_SHA1 (1) +#define MICROPY_PY_CRYPTOLIB (1) +#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/rp2/modutime.c" +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (rosc_random_u32()) #define MICROPY_PY_MACHINE (1) #define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new #define MICROPY_PY_MACHINE_BITSTREAM (1) @@ -151,14 +151,14 @@ #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-rp2" #endif -#ifndef MICROPY_PY_USOCKET -#define MICROPY_PY_USOCKET (1) +#ifndef MICROPY_PY_SOCKET +#define MICROPY_PY_SOCKET (1) #endif -#ifndef MICROPY_PY_USSL -#define MICROPY_PY_USSL (1) +#ifndef MICROPY_PY_SSL +#define MICROPY_PY_SSL (1) #endif -#ifndef MICROPY_PY_UWEBSOCKET -#define MICROPY_PY_UWEBSOCKET (1) +#ifndef MICROPY_PY_WEBSOCKET +#define MICROPY_PY_WEBSOCKET (1) #endif #ifndef MICROPY_PY_WEBREPL #define MICROPY_PY_WEBREPL (1) @@ -181,8 +181,8 @@ extern const struct _mp_obj_type_t mp_network_cyw43_type; #if MICROPY_PY_NETWORK_NINAW10 // This Network interface requires the extended socket state. -#ifndef MICROPY_PY_USOCKET_EXTENDED_STATE -#define MICROPY_PY_USOCKET_EXTENDED_STATE (1) +#ifndef MICROPY_PY_SOCKET_EXTENDED_STATE +#define MICROPY_PY_SOCKET_EXTENDED_STATE (1) #endif extern const struct _mp_obj_type_t mod_network_nic_type_nina; #define MICROPY_HW_NIC_NINAW10 { MP_ROM_QSTR(MP_QSTR_WLAN), MP_ROM_PTR(&mod_network_nic_type_nina) }, diff --git a/ports/samd/mcu/samd21/mpconfigmcu.h b/ports/samd/mcu/samd21/mpconfigmcu.h index df94b9682df..f70981acd53 100644 --- a/ports/samd/mcu/samd21/mpconfigmcu.h +++ b/ports/samd/mcu/samd21/mpconfigmcu.h @@ -14,8 +14,8 @@ #define MICROPY_PY_BUILTINS_COMPLEX (0) #endif -#ifndef MICROPY_PY_UTIME -#define MICROPY_PY_UTIME (1) +#ifndef MICROPY_PY_TIME +#define MICROPY_PY_TIME (1) #endif #ifndef MICROPY_PY_MATH @@ -26,7 +26,7 @@ #define MICROPY_PY_CMATH (0) #endif -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (trng_random_u32(300)) +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (trng_random_u32(300)) unsigned long trng_random_u32(int delay); #define VFS_BLOCK_SIZE_BYTES (1536) // 24x 64B flash pages; @@ -35,7 +35,7 @@ unsigned long trng_random_u32(int delay); #define MICROPY_HW_UART_TXBUF (1) #endif -#define MICROPY_PY_UOS_URANDOM (1) +#define MICROPY_PY_OS_URANDOM (1) #ifndef MICROPY_PY_MACHINE_PIN_BOARD_CPU #define MICROPY_PY_MACHINE_PIN_BOARD_CPU (1) diff --git a/ports/samd/mcu/samd51/mpconfigmcu.h b/ports/samd/mcu/samd51/mpconfigmcu.h index 0c2d2370ffa..1569e5624dd 100644 --- a/ports/samd/mcu/samd51/mpconfigmcu.h +++ b/ports/samd/mcu/samd51/mpconfigmcu.h @@ -27,9 +27,9 @@ #define MICROPY_PY_MACHINE_DHT_READINTO (1) #define MICROPY_PY_ONEWIRE (1) -#define MICROPY_PY_UOS_SYNC (1) -#define MICROPY_PY_UOS_URANDOM (1) -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (trng_random_u32()) +#define MICROPY_PY_OS_SYNC (1) +#define MICROPY_PY_OS_URANDOM (1) +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (trng_random_u32()) unsigned long trng_random_u32(void); #ifndef MICROPY_PY_MACHINE_PIN_BOARD_CPU diff --git a/ports/samd/moduos.c b/ports/samd/moduos.c index 4438bf3c7bb..f9df0cd9969 100644 --- a/ports/samd/moduos.c +++ b/ports/samd/moduos.c @@ -69,7 +69,7 @@ uint32_t trng_random_u32(int delay) { #define TRNG_RANDOM_U32 trng_random_u32(10) #endif -#if MICROPY_PY_UOS_URANDOM +#if MICROPY_PY_OS_URANDOM STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { mp_int_t n = mp_obj_get_int(num); vstr_t vstr; @@ -88,16 +88,16 @@ STATIC mp_obj_t mp_os_urandom(mp_obj_t num) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom); -#endif // MICROPY_PY_UOS_URANDOM +#endif // MICROPY_PY_OS_URANDOM -#if MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM +#if MICROPY_PY_OS_DUPTERM_BUILTIN_STREAM bool mp_os_dupterm_is_builtin_stream(mp_const_obj_t stream) { const mp_obj_type_t *type = mp_obj_get_type(stream); return type == &machine_uart_type; } #endif -#if MICROPY_PY_UOS_DUPTERM_NOTIFY +#if MICROPY_PY_OS_DUPTERM_NOTIFY STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) { (void)obj_in; for (;;) { diff --git a/ports/samd/mpconfigport.h b/ports/samd/mpconfigport.h index a0a58a2fd72..8a9947468e5 100644 --- a/ports/samd/mpconfigport.h +++ b/ports/samd/mpconfigport.h @@ -77,21 +77,21 @@ #define MICROPY_PY_IO_IOBASE (1) // Extended modules -#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/samd/modutime.c" +#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/samd/modtime.c" #define MICROPY_PY_MACHINE (1) -#define MICROPY_PY_UOS (1) -#define MICROPY_PY_UOS_INCLUDEFILE "ports/samd/moduos.c" +#define MICROPY_PY_OS (1) +#define MICROPY_PY_OS_INCLUDEFILE "ports/samd/modos.c" #define MICROPY_READER_VFS (1) #define MICROPY_VFS (1) -#define MICROPY_PY_UJSON (1) -#define MICROPY_PY_URE (1) -#define MICROPY_PY_UBINASCII (1) +#define MICROPY_PY_JSON (1) +#define MICROPY_PY_RE (1) +#define MICROPY_PY_BINASCII (1) #define MICROPY_PY_UCTYPES (1) -#define MICROPY_PY_UHEAPQ (1) -#define MICROPY_PY_URANDOM (1) -#define MICROPY_PY_UZLIB (1) +#define MICROPY_PY_HEAPQ (1) +#define MICROPY_PY_RANDOM (1) +#define MICROPY_PY_ZLIB (1) #define MICROPY_PY_UASYNCIO (1) #define MICROPY_PY_MACHINE_RTC (1) #ifndef MICROPY_PY_MACHINE_ADC diff --git a/ports/stm32/boards/ARDUINO_GIGA/mpconfigboard.mk b/ports/stm32/boards/ARDUINO_GIGA/mpconfigboard.mk index 135b12b8c8c..b927388c557 100644 --- a/ports/stm32/boards/ARDUINO_GIGA/mpconfigboard.mk +++ b/ports/stm32/boards/ARDUINO_GIGA/mpconfigboard.mk @@ -21,7 +21,7 @@ MICROPY_BLUETOOTH_NIMBLE = 1 MICROPY_BLUETOOTH_BTSTACK = 0 MICROPY_PY_LWIP = 1 MICROPY_PY_NETWORK_CYW43 = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/ARDUINO_NICLA_VISION/mpconfigboard.mk b/ports/stm32/boards/ARDUINO_NICLA_VISION/mpconfigboard.mk index ebe9775e807..2c48c17f380 100644 --- a/ports/stm32/boards/ARDUINO_NICLA_VISION/mpconfigboard.mk +++ b/ports/stm32/boards/ARDUINO_NICLA_VISION/mpconfigboard.mk @@ -21,7 +21,7 @@ MICROPY_BLUETOOTH_NIMBLE = 1 MICROPY_BLUETOOTH_BTSTACK = 0 MICROPY_PY_LWIP = 1 MICROPY_PY_NETWORK_CYW43 = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.mk b/ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.mk index 3bfd40dc924..cf4d40e5fe9 100644 --- a/ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.mk +++ b/ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.mk @@ -21,7 +21,7 @@ MICROPY_BLUETOOTH_NIMBLE = 1 MICROPY_BLUETOOTH_BTSTACK = 0 MICROPY_PY_LWIP = 1 MICROPY_PY_NETWORK_CYW43 = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h b/ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h index dfcca72afb5..165284f31ad 100644 --- a/ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h +++ b/ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h @@ -12,13 +12,13 @@ #define MICROPY_PY_GENERATOR_PEND_THROW (0) #define MICROPY_PY_MATH (0) #define MICROPY_PY_FRAMEBUF (0) -#define MICROPY_PY_USOCKET (0) +#define MICROPY_PY_SOCKET (0) #define MICROPY_PY_NETWORK (0) #define MICROPY_PY_ONEWIRE (0) #define MICROPY_PY_STM (0) #define MICROPY_PY_PYB_LEGACY (0) -#define MICROPY_PY_UHEAPQ (0) -#define MICROPY_PY_UTIMEQ (0) +#define MICROPY_PY_HEAPQ (0) +#define MICROPY_PY_TIMEQ (0) #define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0) #define MICROPY_HW_ENABLE_RTC (1) diff --git a/ports/stm32/boards/ESPRUINO_PICO/mpconfigboard.h b/ports/stm32/boards/ESPRUINO_PICO/mpconfigboard.h index ed8178d7d4d..cfc46491e07 100644 --- a/ports/stm32/boards/ESPRUINO_PICO/mpconfigboard.h +++ b/ports/stm32/boards/ESPRUINO_PICO/mpconfigboard.h @@ -4,7 +4,7 @@ #define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_PY_BUILTINS_COMPLEX (0) -#define MICROPY_PY_USOCKET (0) +#define MICROPY_PY_SOCKET (0) #define MICROPY_PY_NETWORK (0) #define MICROPY_HW_HAS_SWITCH (1) diff --git a/ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.h b/ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.h index d44bfb0bb66..39d0082d7bd 100644 --- a/ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.h +++ b/ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.h @@ -5,12 +5,12 @@ #define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_OPT_COMPUTED_GOTO (0) #define MICROPY_PY_BUILTINS_COMPLEX (0) -#define MICROPY_PY_USOCKET (0) +#define MICROPY_PY_SOCKET (0) #define MICROPY_PY_NETWORK (0) #define MICROPY_PY_STM (0) #define MICROPY_PY_PYB_LEGACY (0) -#define MICROPY_PY_UHEAPQ (0) -#define MICROPY_PY_UTIMEQ (0) +#define MICROPY_PY_HEAPQ (0) +#define MICROPY_PY_TIMEQ (0) #define MICROPY_PY_FRAMEBUF (0) #define MICROPY_HW_ENABLE_RTC (1) diff --git a/ports/stm32/boards/NUCLEO_F429ZI/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_F429ZI/mpconfigboard.mk index 9e82be1dc73..e5fc89ab47a 100644 --- a/ports/stm32/boards/NUCLEO_F429ZI/mpconfigboard.mk +++ b/ports/stm32/boards/NUCLEO_F429ZI/mpconfigboard.mk @@ -7,7 +7,7 @@ TEXT1_ADDR = 0x08020000 # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/NUCLEO_F439ZI/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_F439ZI/mpconfigboard.mk index 69b0f80a2d2..b8666755b03 100644 --- a/ports/stm32/boards/NUCLEO_F439ZI/mpconfigboard.mk +++ b/ports/stm32/boards/NUCLEO_F439ZI/mpconfigboard.mk @@ -7,7 +7,7 @@ TEXT1_ADDR = 0x08020000 # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/NUCLEO_F746ZG/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_F746ZG/mpconfigboard.mk index 9506b675955..20acc63f160 100644 --- a/ports/stm32/boards/NUCLEO_F746ZG/mpconfigboard.mk +++ b/ports/stm32/boards/NUCLEO_F746ZG/mpconfigboard.mk @@ -7,7 +7,7 @@ TEXT1_ADDR = 0x08020000 # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/NUCLEO_F756ZG/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_F756ZG/mpconfigboard.mk index 90fc242f9ac..ab3eada5b06 100644 --- a/ports/stm32/boards/NUCLEO_F756ZG/mpconfigboard.mk +++ b/ports/stm32/boards/NUCLEO_F756ZG/mpconfigboard.mk @@ -7,7 +7,7 @@ TEXT1_ADDR = 0x08020000 # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.mk index 6ef9d42f9d3..22c40981591 100644 --- a/ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.mk +++ b/ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.mk @@ -8,7 +8,7 @@ TEXT1_ADDR = 0x08020000 # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/NUCLEO_G474RE/mpconfigboard.h b/ports/stm32/boards/NUCLEO_G474RE/mpconfigboard.h index 31157dd2c4d..336d95c42c6 100644 --- a/ports/stm32/boards/NUCLEO_G474RE/mpconfigboard.h +++ b/ports/stm32/boards/NUCLEO_G474RE/mpconfigboard.h @@ -10,13 +10,13 @@ #define MICROPY_HW_HAS_FLASH (0) // QSPI extflash not mounted #define MICROPY_PY_UASYNCIO (0) -#define MICROPY_PY_UZLIB (0) -#define MICROPY_PY_UBINASCII (0) -#define MICROPY_PY_UHASHLIB (0) -#define MICROPY_PY_UJSON (0) -#define MICROPY_PY_URE (0) +#define MICROPY_PY_ZLIB (0) +#define MICROPY_PY_BINASCII (0) +#define MICROPY_PY_HASHLIB (0) +#define MICROPY_PY_JSON (0) +#define MICROPY_PY_RE (0) #define MICROPY_PY_FRAMEBUF (0) -#define MICROPY_PY_USOCKET (0) +#define MICROPY_PY_SOCKET (0) #define MICROPY_PY_NETWORK (0) // The board has an 24MHz HSE, the following gives 170MHz CPU speed diff --git a/ports/stm32/boards/NUCLEO_H723ZG/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_H723ZG/mpconfigboard.mk index 287b51f6d83..6d512ec0eda 100644 --- a/ports/stm32/boards/NUCLEO_H723ZG/mpconfigboard.mk +++ b/ports/stm32/boards/NUCLEO_H723ZG/mpconfigboard.mk @@ -18,7 +18,7 @@ endif # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 MICROPY_VFS_LFS2 = 1 diff --git a/ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk index ea95fd00743..cbdf48c52a8 100644 --- a/ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk +++ b/ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk @@ -18,7 +18,7 @@ endif # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 MICROPY_VFS_LFS2 = 1 diff --git a/ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.h b/ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.h index c8c809eb489..1d6b303260d 100644 --- a/ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.h +++ b/ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.h @@ -12,13 +12,13 @@ #define MICROPY_PY_GENERATOR_PEND_THROW (0) #define MICROPY_PY_MATH (0) #define MICROPY_PY_FRAMEBUF (0) -#define MICROPY_PY_USOCKET (0) +#define MICROPY_PY_SOCKET (0) #define MICROPY_PY_NETWORK (0) #define MICROPY_PY_ONEWIRE (0) #define MICROPY_PY_STM (0) #define MICROPY_PY_PYB_LEGACY (0) -#define MICROPY_PY_UHEAPQ (0) -#define MICROPY_PY_UTIMEQ (0) +#define MICROPY_PY_HEAPQ (0) +#define MICROPY_PY_TIMEQ (0) #define MICROPY_PY_MACHINE_BITSTREAM (0) diff --git a/ports/stm32/boards/NUCLEO_L432KC/mpconfigboard.h b/ports/stm32/boards/NUCLEO_L432KC/mpconfigboard.h index 5e05053cdd9..ba843c8a611 100644 --- a/ports/stm32/boards/NUCLEO_L432KC/mpconfigboard.h +++ b/ports/stm32/boards/NUCLEO_L432KC/mpconfigboard.h @@ -6,13 +6,13 @@ #define MICROPY_OPT_COMPUTED_GOTO (0) #define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_GENERATOR_PEND_THROW (0) -#define MICROPY_PY_USOCKET (0) +#define MICROPY_PY_SOCKET (0) #define MICROPY_PY_NETWORK (0) #define MICROPY_PY_ONEWIRE (0) #define MICROPY_PY_STM (0) #define MICROPY_PY_PYB_LEGACY (0) -#define MICROPY_PY_UHEAPQ (0) -#define MICROPY_PY_UTIMEQ (0) +#define MICROPY_PY_HEAPQ (0) +#define MICROPY_PY_TIMEQ (0) #define MICROPY_HW_ENABLE_RTC (1) #define MICROPY_HW_ENABLE_ADC (1) diff --git a/ports/stm32/boards/NUCLEO_L452RE/mpconfigboard.h b/ports/stm32/boards/NUCLEO_L452RE/mpconfigboard.h index 1b5827d5aec..b0fab459567 100644 --- a/ports/stm32/boards/NUCLEO_L452RE/mpconfigboard.h +++ b/ports/stm32/boards/NUCLEO_L452RE/mpconfigboard.h @@ -1,7 +1,7 @@ #define MICROPY_HW_BOARD_NAME "NUCLEO-L452RE" #define MICROPY_HW_MCU_NAME "STM32L452RE" -#define MICROPY_PY_USOCKET (0) +#define MICROPY_PY_SOCKET (0) #define MICROPY_PY_NETWORK (0) #define MICROPY_HW_ENABLE_RTC (1) diff --git a/ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h b/ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h index baf1f023be8..2bb368adccd 100644 --- a/ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h +++ b/ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h @@ -11,13 +11,13 @@ #define MICROPY_PY_GENERATOR_PEND_THROW (0) #define MICROPY_PY_MATH (0) #define MICROPY_PY_FRAMEBUF (0) -#define MICROPY_PY_USOCKET (0) +#define MICROPY_PY_SOCKET (0) #define MICROPY_PY_NETWORK (0) #define MICROPY_PY_ONEWIRE (0) #define MICROPY_PY_STM (0) #define MICROPY_PY_PYB_LEGACY (0) -#define MICROPY_PY_UHEAPQ (0) -#define MICROPY_PY_UTIMEQ (0) +#define MICROPY_PY_HEAPQ (0) +#define MICROPY_PY_TIMEQ (0) #define MICROPY_HW_HAS_FLASH (1) #define MICROPY_HW_ENABLE_RTC (1) diff --git a/ports/stm32/boards/OLIMEX_E407/mpconfigboard.mk b/ports/stm32/boards/OLIMEX_E407/mpconfigboard.mk index 0d3eee83be2..aa11fd5492d 100644 --- a/ports/stm32/boards/OLIMEX_E407/mpconfigboard.mk +++ b/ports/stm32/boards/OLIMEX_E407/mpconfigboard.mk @@ -7,5 +7,5 @@ TEXT1_ADDR = 0x08020000 # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 diff --git a/ports/stm32/boards/PYBD_SF2/mpconfigboard.mk b/ports/stm32/boards/PYBD_SF2/mpconfigboard.mk index 6615a44a538..ee481e344f0 100644 --- a/ports/stm32/boards/PYBD_SF2/mpconfigboard.mk +++ b/ports/stm32/boards/PYBD_SF2/mpconfigboard.mk @@ -15,7 +15,7 @@ MICROPY_BLUETOOTH_NIMBLE ?= 1 MICROPY_BLUETOOTH_BTSTACK ?= 0 MICROPY_PY_LWIP = 1 MICROPY_PY_NETWORK_CYW43 = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 MICROPY_VFS_LFS2 = 1 diff --git a/ports/stm32/boards/PYBD_SF3/mpconfigboard.mk b/ports/stm32/boards/PYBD_SF3/mpconfigboard.mk index 550094b7439..cb8c44361cb 100644 --- a/ports/stm32/boards/PYBD_SF3/mpconfigboard.mk +++ b/ports/stm32/boards/PYBD_SF3/mpconfigboard.mk @@ -15,7 +15,7 @@ MICROPY_BLUETOOTH_NIMBLE ?= 1 MICROPY_BLUETOOTH_BTSTACK ?= 0 MICROPY_PY_LWIP = 1 MICROPY_PY_NETWORK_CYW43 = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 MICROPY_VFS_LFS2 = 1 diff --git a/ports/stm32/boards/PYBD_SF6/mpconfigboard.mk b/ports/stm32/boards/PYBD_SF6/mpconfigboard.mk index 9db2210559a..943ddf60d33 100644 --- a/ports/stm32/boards/PYBD_SF6/mpconfigboard.mk +++ b/ports/stm32/boards/PYBD_SF6/mpconfigboard.mk @@ -12,7 +12,7 @@ MICROPY_BLUETOOTH_NIMBLE ?= 1 MICROPY_BLUETOOTH_BTSTACK ?= 0 MICROPY_PY_LWIP = 1 MICROPY_PY_NETWORK_CYW43 = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 MICROPY_VFS_LFS2 = 1 diff --git a/ports/stm32/boards/STM32F769DISC/mpconfigboard.mk b/ports/stm32/boards/STM32F769DISC/mpconfigboard.mk index 6457fc6046b..712906747cc 100644 --- a/ports/stm32/boards/STM32F769DISC/mpconfigboard.mk +++ b/ports/stm32/boards/STM32F769DISC/mpconfigboard.mk @@ -42,7 +42,7 @@ endif # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/STM32F7DISC/mpconfigboard.mk b/ports/stm32/boards/STM32F7DISC/mpconfigboard.mk index 9506b675955..20acc63f160 100644 --- a/ports/stm32/boards/STM32F7DISC/mpconfigboard.mk +++ b/ports/stm32/boards/STM32F7DISC/mpconfigboard.mk @@ -7,7 +7,7 @@ TEXT1_ADDR = 0x08020000 # MicroPython settings MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/boards/VCC_GND_F407ZG/mpconfigboard.mk b/ports/stm32/boards/VCC_GND_F407ZG/mpconfigboard.mk index a30a6137d3b..2d3e4cec4f8 100644 --- a/ports/stm32/boards/VCC_GND_F407ZG/mpconfigboard.mk +++ b/ports/stm32/boards/VCC_GND_F407ZG/mpconfigboard.mk @@ -6,7 +6,7 @@ TEXT0_ADDR = 0x08000000 TEXT1_ADDR = 0x08020000 MICROPY_PY_LWIP = 1 -MICROPY_PY_USSL = 1 +MICROPY_PY_SSL = 1 MICROPY_SSL_MBEDTLS = 1 FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py diff --git a/ports/stm32/moduos.c b/ports/stm32/moduos.c index bfbb868e2fb..43543aa55e2 100644 --- a/ports/stm32/moduos.c +++ b/ports/stm32/moduos.c @@ -29,7 +29,7 @@ #include "usb.h" #include "uart.h" -#if MICROPY_PY_UOS_URANDOM +#if MICROPY_PY_OS_URANDOM // urandom(n) // Return a bytes object with n random bytes, generated by the hardware // random number generator. diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index 62784dccf10..49a8a034052 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -92,24 +92,24 @@ #endif // extended modules -#define MICROPY_PY_USSL_FINALISER (MICROPY_PY_USSL) -#define MICROPY_PY_UHASHLIB_MD5 (MICROPY_PY_USSL) -#define MICROPY_PY_UHASHLIB_SHA1 (MICROPY_PY_USSL) -#define MICROPY_PY_UCRYPTOLIB (MICROPY_PY_USSL) -#define MICROPY_PY_UOS_INCLUDEFILE "ports/stm32/moduos.c" +#define MICROPY_PY_SSL_FINALISER (MICROPY_PY_SSL) +#define MICROPY_PY_HASHLIB_MD5 (MICROPY_PY_SSL) +#define MICROPY_PY_HASHLIB_SHA1 (MICROPY_PY_SSL) +#define MICROPY_PY_CRYPTOLIB (MICROPY_PY_SSL) +#define MICROPY_PY_OS_INCLUDEFILE "ports/stm32/moduos.c" #define MICROPY_PY_OS_DUPTERM (3) -#define MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM (1) -#define MICROPY_PY_UOS_DUPTERM_STREAM_DETACHED_ATTACHED (1) -#define MICROPY_PY_UOS_SEP (1) -#define MICROPY_PY_UOS_SYNC (1) -#define MICROPY_PY_UOS_UNAME (1) -#define MICROPY_PY_UOS_URANDOM (MICROPY_HW_ENABLE_RNG) -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (rng_get()) -#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/stm32/modutime.c" -#ifndef MICROPY_PY_UTIMEQ -#define MICROPY_PY_UTIMEQ (1) +#define MICROPY_PY_OS_DUPTERM_BUILTIN_STREAM (1) +#define MICROPY_PY_OS_DUPTERM_STREAM_DETACHED_ATTACHED (1) +#define MICROPY_PY_OS_SEP (1) +#define MICROPY_PY_OS_SYNC (1) +#define MICROPY_PY_OS_UNAME (1) +#define MICROPY_PY_OS_URANDOM (MICROPY_HW_ENABLE_RNG) +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (rng_get()) +#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/stm32/modutime.c" +#ifndef MICROPY_PY_TIMEQ +#define MICROPY_PY_TIMEQ (1) #endif #define MICROPY_PY_LWIP_SOCK_RAW (MICROPY_PY_LWIP) #ifndef MICROPY_PY_MACHINE @@ -130,10 +130,10 @@ #endif #define MICROPY_HW_SOFTSPI_MIN_DELAY (0) #define MICROPY_HW_SOFTSPI_MAX_BAUDRATE (HAL_RCC_GetSysClockFreq() / 48) -#define MICROPY_PY_UWEBSOCKET (MICROPY_PY_LWIP) +#define MICROPY_PY_WEBSOCKET (MICROPY_PY_LWIP) #define MICROPY_PY_WEBREPL (MICROPY_PY_LWIP) -#ifndef MICROPY_PY_USOCKET -#define MICROPY_PY_USOCKET (1) +#ifndef MICROPY_PY_SOCKET +#define MICROPY_PY_SOCKET (1) #endif #ifndef MICROPY_PY_NETWORK #define MICROPY_PY_NETWORK (1) @@ -141,8 +141,8 @@ #ifndef MICROPY_PY_ONEWIRE #define MICROPY_PY_ONEWIRE (1) #endif -#ifndef MICROPY_PY_UPLATFORM -#define MICROPY_PY_UPLATFORM (1) +#ifndef MICROPY_PY_PLATFORM +#define MICROPY_PY_PLATFORM (1) #endif // fatfs configuration used in ffconf.h @@ -324,5 +324,5 @@ static inline mp_uint_t disable_irq(void) { // We need to provide a declaration/definition of alloca() #include -// Needed for MICROPY_PY_URANDOM_SEED_INIT_FUNC. +// Needed for MICROPY_PY_RANDOM_SEED_INIT_FUNC. uint32_t rng_get(void); diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 0ff2e4b6e8f..9ff19aab988 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -138,7 +138,7 @@ CFLAGS += -DMICROPY_PY_THREAD=1 -DMICROPY_PY_THREAD_GIL=0 LDFLAGS += $(LIBPTHREAD) endif -ifeq ($(MICROPY_PY_USSL),1) +ifeq ($(MICROPY_PY_SSL),1) ifeq ($(MICROPY_SSL_AXTLS),1) endif diff --git a/ports/unix/README.md b/ports/unix/README.md index a3a0dba75a1..a3159a3262e 100644 --- a/ports/unix/README.md +++ b/ports/unix/README.md @@ -70,5 +70,5 @@ or not). If you intend to build MicroPython with additional options (like cross-compiling), the same set of options should be passed to `make deplibs`. To actually enable/disable use of dependencies, edit the `ports/unix/mpconfigport.mk` file, which has inline descriptions of the -options. For example, to build the SSL module, `MICROPY_PY_USSL` should be +options. For example, to build the SSL module, `MICROPY_PY_SSL` should be set to 1. diff --git a/ports/unix/mbedtls/mbedtls_config.h b/ports/unix/mbedtls/mbedtls_config.h index c8ffab0832a..629064abcf2 100644 --- a/ports/unix/mbedtls/mbedtls_config.h +++ b/ports/unix/mbedtls/mbedtls_config.h @@ -27,7 +27,7 @@ #define MICROPY_INCLUDED_MBEDTLS_CONFIG_H // Set mbedtls configuration -#define MBEDTLS_CIPHER_MODE_CTR // needed for MICROPY_PY_UCRYPTOLIB_CTR +#define MBEDTLS_CIPHER_MODE_CTR // needed for MICROPY_PY_CRYPTOLIB_CTR // Enable mbedtls modules #define MBEDTLS_HAVEGE_C diff --git a/ports/unix/moduselect.c b/ports/unix/moduselect.c index 9f7f452a129..97c3602e4bc 100644 --- a/ports/unix/moduselect.c +++ b/ports/unix/moduselect.c @@ -27,10 +27,10 @@ #include "py/mpconfig.h" -#if MICROPY_PY_USELECT_POSIX +#if MICROPY_PY_SELECT_POSIX -#if MICROPY_PY_USELECT -#error "Can't have both MICROPY_PY_USELECT and MICROPY_PY_USELECT_POSIX." +#if MICROPY_PY_SELECT +#error "Can't have both MICROPY_PY_SELECT and MICROPY_PY_SELECT_POSIX." #endif #include @@ -353,4 +353,4 @@ const mp_obj_module_t mp_module_select = { MP_REGISTER_MODULE(MP_QSTR_select, mp_module_select); -#endif // MICROPY_PY_USELECT_POSIX +#endif // MICROPY_PY_SELECT_POSIX diff --git a/ports/unix/modusocket.c b/ports/unix/modusocket.c index d8a615b4696..9854f3cbce1 100644 --- a/ports/unix/modusocket.c +++ b/ports/unix/modusocket.c @@ -146,7 +146,7 @@ STATIC mp_uint_t socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, i case MP_STREAM_GET_FILENO: return self->fd; - #if MICROPY_PY_USELECT + #if MICROPY_PY_SELECT case MP_STREAM_POLL: { mp_uint_t ret = 0; uint8_t pollevents = 0; @@ -227,7 +227,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind); STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) { mp_obj_socket_t *self = MP_OBJ_TO_PTR(args[0]); - int backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT; + int backlog = MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT; if (n_args > 1) { backlog = (int)mp_obj_get_int(args[1]); backlog = (backlog < 0) ? 0 : backlog; diff --git a/ports/unix/modutime.c b/ports/unix/modutime.c index 26c2fbdb900..b6fbae0d1c2 100644 --- a/ports/unix/modutime.c +++ b/ports/unix/modutime.c @@ -200,7 +200,7 @@ STATIC mp_obj_t mod_time_mktime(mp_obj_t tuple) { } MP_DEFINE_CONST_FUN_OBJ_1(mod_time_mktime_obj, mod_time_mktime); -#define MICROPY_PY_UTIME_EXTRA_GLOBALS \ +#define MICROPY_PY_TIME_EXTRA_GLOBALS \ { MP_ROM_QSTR(MP_QSTR_clock), MP_ROM_PTR(&mod_time_clock_obj) }, \ { MP_ROM_QSTR(MP_QSTR_gmtime), MP_ROM_PTR(&mod_time_gmtime_obj) }, \ { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&mod_time_localtime_obj) }, \ diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index 0588e100d6c..58aba9700bd 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -160,7 +160,7 @@ typedef long mp_off_t; // Enable sys.executable. #define MICROPY_PY_SYS_EXECUTABLE (1) -#define MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT (SOMAXCONN < 128 ? SOMAXCONN : 128) +#define MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT (SOMAXCONN < 128 ? SOMAXCONN : 128) // Bare-metal ports don't have stderr. Printing debug to stderr may give tests // which check stdout a chance to pass, etc. @@ -181,7 +181,7 @@ void mp_unix_mark_exec(void); #endif // If enabled, configure how to seed random on init. -#ifdef MICROPY_PY_URANDOM_SEED_INIT_FUNC +#ifdef MICROPY_PY_RANDOM_SEED_INIT_FUNC #include void mp_hal_get_random(size_t n, void *buf); static inline unsigned long mp_random_seed_init(void) { diff --git a/ports/unix/mpconfigport.mk b/ports/unix/mpconfigport.mk index ce6183c1339..c8ade0b7e27 100644 --- a/ports/unix/mpconfigport.mk +++ b/ports/unix/mpconfigport.mk @@ -23,8 +23,8 @@ MICROPY_PY_SOCKET = 1 # ffi module requires libffi (libffi-dev Debian package) MICROPY_PY_FFI = 1 -# ussl module requires one of the TLS libraries below -MICROPY_PY_USSL = 1 +# ssl module requires one of the TLS libraries below +MICROPY_PY_SSL = 1 # axTLS has minimal size but implements only a subset of modern TLS # functionality, so may have problems with some servers. MICROPY_SSL_AXTLS = 0 diff --git a/ports/unix/variants/coverage/mpconfigvariant.h b/ports/unix/variants/coverage/mpconfigvariant.h index 2a48e57e7f0..e24e0f1b14a 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.h +++ b/ports/unix/variants/coverage/mpconfigvariant.h @@ -41,4 +41,4 @@ #define MICROPY_DEBUG_PARSE_RULE_NAME (1) #define MICROPY_TRACKED_ALLOC (1) #define MICROPY_WARNINGS_CATEGORY (1) -#define MICROPY_PY_UCRYPTOLIB_CTR (1) +#define MICROPY_PY_CRYPTOLIB_CTR (1) diff --git a/ports/unix/variants/minimal/mpconfigvariant.h b/ports/unix/variants/minimal/mpconfigvariant.h index 6b107e77909..0dbfbb3d1cd 100644 --- a/ports/unix/variants/minimal/mpconfigvariant.h +++ b/ports/unix/variants/minimal/mpconfigvariant.h @@ -63,7 +63,7 @@ // Enable just the sys and os built-in modules. #define MICROPY_PY_SYS (1) -#define MICROPY_PY_UOS (1) +#define MICROPY_PY_OS (1) // The minimum sets this to 1 to save flash. #define MICROPY_QSTR_BYTES_IN_HASH (2) diff --git a/ports/unix/variants/minimal/mpconfigvariant.mk b/ports/unix/variants/minimal/mpconfigvariant.mk index d5c2a52e9ae..19b3460ed59 100644 --- a/ports/unix/variants/minimal/mpconfigvariant.mk +++ b/ports/unix/variants/minimal/mpconfigvariant.mk @@ -7,7 +7,7 @@ MICROPY_PY_FFI = 0 MICROPY_PY_SOCKET = 0 MICROPY_PY_THREAD = 0 MICROPY_PY_TERMIOS = 0 -MICROPY_PY_USSL = 0 +MICROPY_PY_SSL = 0 MICROPY_USE_READLINE = 0 MICROPY_VFS_FAT = 0 diff --git a/ports/unix/variants/mpconfigvariant_common.h b/ports/unix/variants/mpconfigvariant_common.h index 9a8a524a226..cc50d426ceb 100644 --- a/ports/unix/variants/mpconfigvariant_common.h +++ b/ports/unix/variants/mpconfigvariant_common.h @@ -58,7 +58,7 @@ #endif // Seed random on import. -#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (mp_random_seed_init()) +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (mp_random_seed_init()) // Allow exception details in low-memory conditions. #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1) @@ -87,39 +87,39 @@ #define MICROPY_PY_SYS_EXC_INFO (1) // Configure the "os" module with extra unix features. -#define MICROPY_PY_UOS_INCLUDEFILE "ports/unix/moduos.c" -#define MICROPY_PY_UOS_ERRNO (1) -#define MICROPY_PY_UOS_GETENV_PUTENV_UNSETENV (1) -#define MICROPY_PY_UOS_SEP (1) -#define MICROPY_PY_UOS_SYSTEM (1) -#define MICROPY_PY_UOS_URANDOM (1) +#define MICROPY_PY_OS_INCLUDEFILE "ports/unix/moduos.c" +#define MICROPY_PY_OS_ERRNO (1) +#define MICROPY_PY_OS_GETENV_PUTENV_UNSETENV (1) +#define MICROPY_PY_OS_SEP (1) +#define MICROPY_PY_OS_SYSTEM (1) +#define MICROPY_PY_OS_URANDOM (1) // Enable the unix-specific "time" module. -#define MICROPY_PY_UTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_CUSTOM_SLEEP (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/unix/modutime.c" +#define MICROPY_PY_TIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_CUSTOM_SLEEP (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/unix/modutime.c" // Enable the utimeq module used by the previous (v2) version of uasyncio. -#define MICROPY_PY_UTIMEQ (1) +#define MICROPY_PY_TIMEQ (1) -#if MICROPY_PY_USSL -#define MICROPY_PY_UHASHLIB_MD5 (1) -#define MICROPY_PY_UHASHLIB_SHA1 (1) -#define MICROPY_PY_UCRYPTOLIB (1) +#if MICROPY_PY_SSL +#define MICROPY_PY_HASHLIB_MD5 (1) +#define MICROPY_PY_HASHLIB_SHA1 (1) +#define MICROPY_PY_CRYPTOLIB (1) #endif // Use the posix implementation of the "select" module (unless the variant // specifically asks for the MicroPython version). -#ifndef MICROPY_PY_USELECT -#define MICROPY_PY_USELECT (0) +#ifndef MICROPY_PY_SELECT +#define MICROPY_PY_SELECT (0) #endif -#ifndef MICROPY_PY_USELECT_POSIX -#define MICROPY_PY_USELECT_POSIX (!MICROPY_PY_USELECT) +#ifndef MICROPY_PY_SELECT_POSIX +#define MICROPY_PY_SELECT_POSIX (!MICROPY_PY_SELECT) #endif // Enable the "websocket" module. -#define MICROPY_PY_UWEBSOCKET (1) +#define MICROPY_PY_WEBSOCKET (1) // Enable the "machine" module, mostly for machine.mem*. #define MICROPY_PY_MACHINE (1) diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h index 5e56923d93b..87e12562b16 100644 --- a/ports/windows/mpconfigport.h +++ b/ports/windows/mpconfigport.h @@ -130,29 +130,29 @@ #define MICROPY_STACKLESS_STRICT (0) #endif -#define MICROPY_PY_UOS (1) -#define MICROPY_PY_UOS_INCLUDEFILE "ports/unix/moduos.c" -#define MICROPY_PY_UOS_ERRNO (1) -#define MICROPY_PY_UOS_GETENV_PUTENV_UNSETENV (1) -#define MICROPY_PY_UOS_SEP (1) -#define MICROPY_PY_UOS_STATVFS (0) -#define MICROPY_PY_UOS_SYSTEM (1) -#define MICROPY_PY_UOS_URANDOM (1) -#define MICROPY_PY_UTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_CUSTOM_SLEEP (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/unix/modutime.c" -#define MICROPY_PY_UERRNO (1) +#define MICROPY_PY_OS (1) +#define MICROPY_PY_OS_INCLUDEFILE "ports/unix/moduos.c" +#define MICROPY_PY_OS_ERRNO (1) +#define MICROPY_PY_OS_GETENV_PUTENV_UNSETENV (1) +#define MICROPY_PY_OS_SEP (1) +#define MICROPY_PY_OS_STATVFS (0) +#define MICROPY_PY_OS_SYSTEM (1) +#define MICROPY_PY_OS_URANDOM (1) +#define MICROPY_PY_TIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_CUSTOM_SLEEP (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/unix/modutime.c" +#define MICROPY_PY_ERRNO (1) #define MICROPY_PY_UCTYPES (1) -#define MICROPY_PY_UZLIB (1) -#define MICROPY_PY_UJSON (1) -#define MICROPY_PY_URE (1) -#define MICROPY_PY_UHEAPQ (1) -#define MICROPY_PY_UTIMEQ (1) -#define MICROPY_PY_UHASHLIB (1) -#define MICROPY_PY_UBINASCII (1) -#define MICROPY_PY_UBINASCII_CRC32 (1) -#define MICROPY_PY_URANDOM (1) +#define MICROPY_PY_ZLIB (1) +#define MICROPY_PY_JSON (1) +#define MICROPY_PY_RE (1) +#define MICROPY_PY_HEAPQ (1) +#define MICROPY_PY_TIMEQ (1) +#define MICROPY_PY_HASHLIB (1) +#define MICROPY_PY_BINASCII (1) +#define MICROPY_PY_BINASCII_CRC32 (1) +#define MICROPY_PY_RANDOM (1) #define MICROPY_PY_MACHINE (1) #define MICROPY_PY_MACHINE_PULSE (1) #define MICROPY_MACHINE_MEM_GET_READ_ADDR mod_machine_mem_get_addr diff --git a/ports/windows/variants/dev/mpconfigvariant.h b/ports/windows/variants/dev/mpconfigvariant.h index abf43a0da92..d6ce7bf36f9 100644 --- a/ports/windows/variants/dev/mpconfigvariant.h +++ b/ports/windows/variants/dev/mpconfigvariant.h @@ -34,9 +34,9 @@ #define MICROPY_PY_SYS_SETTRACE (1) #define MICROPY_PERSISTENT_CODE_SAVE (1) #define MICROPY_COMP_CONST (0) -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) +#define MICROPY_PY_RANDOM_EXTRA_FUNCS (1) #define MICROPY_PY_BUILTINS_SLICE_INDICES (1) -#define MICROPY_PY_USELECT (1) +#define MICROPY_PY_SELECT (1) #ifndef MICROPY_PY_UASYNCIO #define MICROPY_PY_UASYNCIO (1) diff --git a/ports/zephyr/modusocket.c b/ports/zephyr/modusocket.c index c3356189ab7..8d4197410c2 100644 --- a/ports/zephyr/modusocket.c +++ b/ports/zephyr/modusocket.c @@ -25,7 +25,7 @@ */ #include "py/mpconfig.h" -#ifdef MICROPY_PY_USOCKET +#ifdef MICROPY_PY_SOCKET #include "py/runtime.h" #include "py/stream.h" @@ -190,7 +190,7 @@ STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) { socket_obj_t *socket = args[0]; socket_check_closed(socket); - mp_int_t backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT; + mp_int_t backlog = MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT; if (n_args > 1) { backlog = mp_obj_get_int(args[1]); backlog = (backlog < 0) ? 0 : backlog; @@ -475,4 +475,4 @@ const mp_obj_module_t mp_module_socket = { MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); -#endif // MICROPY_PY_USOCKET +#endif // MICROPY_PY_SOCKET diff --git a/ports/zephyr/modzsensor.c b/ports/zephyr/modzsensor.c index e35a1716f47..5b55f0ebbaa 100644 --- a/ports/zephyr/modzsensor.c +++ b/ports/zephyr/modzsensor.c @@ -145,4 +145,4 @@ const mp_obj_module_t mp_module_zsensor = { MP_REGISTER_MODULE(MP_QSTR_zsensor, mp_module_zsensor); -#endif // MICROPY_PY_UHASHLIB +#endif // MICROPY_PY_HASHLIB diff --git a/ports/zephyr/mpconfigport.h b/ports/zephyr/mpconfigport.h index 30ccccb6272..ec759bda775 100644 --- a/ports/zephyr/mpconfigport.h +++ b/ports/zephyr/mpconfigport.h @@ -72,8 +72,8 @@ #define MICROPY_PY_STRUCT (0) #ifdef CONFIG_NETWORKING // If we have networking, we likely want errno comfort -#define MICROPY_PY_UERRNO (1) -#define MICROPY_PY_USOCKET (1) +#define MICROPY_PY_ERRNO (1) +#define MICROPY_PY_SOCKET (1) #endif #ifdef CONFIG_BT #define MICROPY_PY_BLUETOOTH (1) @@ -82,12 +82,12 @@ #endif #define MICROPY_PY_BLUETOOTH_ENABLE_GATT_CLIENT (0) #endif -#define MICROPY_PY_UBINASCII (1) -#define MICROPY_PY_UHASHLIB (1) -#define MICROPY_PY_UOS (1) -#define MICROPY_PY_UTIME (1) -#define MICROPY_PY_UTIME_TIME_TIME_NS (1) -#define MICROPY_PY_UTIME_INCLUDEFILE "ports/zephyr/modutime.c" +#define MICROPY_PY_BINASCII (1) +#define MICROPY_PY_HASHLIB (1) +#define MICROPY_PY_OS (1) +#define MICROPY_PY_TIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/zephyr/modutime.c" #define MICROPY_PY_ZEPHYR (1) #define MICROPY_PY_ZSENSOR (1) #define MICROPY_PY_SYS_MODULES (0) diff --git a/ports/zephyr/prj.conf b/ports/zephyr/prj.conf index 90211e36579..6046690197c 100644 --- a/ports/zephyr/prj.conf +++ b/ports/zephyr/prj.conf @@ -57,7 +57,7 @@ CONFIG_THREAD_ANALYZER=y CONFIG_THREAD_ANALYZER_USE_PRINTK=y CONFIG_THREAD_NAME=y -# Required for usocket.pkt_get_info() +# Required for socket.pkt_get_info() CONFIG_NET_BUF_POOL_USAGE=y # Required for zephyr.shell_exec() diff --git a/py/moduerrno.c b/py/moduerrno.c index ed172ae4d6e..99ca101bd6e 100644 --- a/py/moduerrno.c +++ b/py/moduerrno.c @@ -30,12 +30,12 @@ #include "py/obj.h" #include "py/mperrno.h" -#if MICROPY_PY_UERRNO +#if MICROPY_PY_ERRNO // This list can be defined per port in mpconfigport.h to tailor it to a // specific port's needs. If it's not defined then we provide a default. -#ifndef MICROPY_PY_UERRNO_LIST -#define MICROPY_PY_UERRNO_LIST \ +#ifndef MICROPY_PY_ERRNO_LIST +#define MICROPY_PY_ERRNO_LIST \ X(EPERM) \ X(ENOENT) \ X(EIO) \ @@ -61,10 +61,10 @@ #endif -#if MICROPY_PY_UERRNO_ERRORCODE +#if MICROPY_PY_ERRNO_ERRORCODE STATIC const mp_rom_map_elem_t errorcode_table[] = { #define X(e) { MP_ROM_INT(MP_##e), MP_ROM_QSTR(MP_QSTR_##e) }, - MICROPY_PY_UERRNO_LIST + MICROPY_PY_ERRNO_LIST #undef X }; @@ -83,12 +83,12 @@ STATIC const mp_obj_dict_t errorcode_dict = { STATIC const mp_rom_map_elem_t mp_module_errno_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_errno) }, - #if MICROPY_PY_UERRNO_ERRORCODE + #if MICROPY_PY_ERRNO_ERRORCODE { MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) }, #endif #define X(e) { MP_ROM_QSTR(MP_QSTR_##e), MP_ROM_INT(MP_##e) }, - MICROPY_PY_UERRNO_LIST + MICROPY_PY_ERRNO_LIST #undef X }; @@ -102,7 +102,7 @@ const mp_obj_module_t mp_module_errno = { MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_errno); qstr mp_errno_to_str(mp_obj_t errno_val) { - #if MICROPY_PY_UERRNO_ERRORCODE + #if MICROPY_PY_ERRNO_ERRORCODE // We have the errorcode dict so can do a lookup using the hash map mp_map_elem_t *elem = mp_map_lookup((mp_map_t *)&errorcode_dict.map, errno_val, MP_MAP_LOOKUP); if (elem == NULL) { @@ -121,4 +121,4 @@ qstr mp_errno_to_str(mp_obj_t errno_val) { #endif } -#endif // MICROPY_PY_UERRNO +#endif // MICROPY_PY_ERRNO diff --git a/py/mpconfig.h b/py/mpconfig.h index fbe8ba54e2d..a004f548ad9 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1459,40 +1459,40 @@ typedef double mp_float_t; #endif // Whether to provide "errno" module -#ifndef MICROPY_PY_UERRNO -#define MICROPY_PY_UERRNO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_ERRNO +#define MICROPY_PY_ERRNO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the errno.errorcode dict -#ifndef MICROPY_PY_UERRNO_ERRORCODE -#define MICROPY_PY_UERRNO_ERRORCODE (1) +#ifndef MICROPY_PY_ERRNO_ERRORCODE +#define MICROPY_PY_ERRNO_ERRORCODE (1) #endif // Whether to provide "select" module (baremetal implementation) -#ifndef MICROPY_PY_USELECT -#define MICROPY_PY_USELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_SELECT +#define MICROPY_PY_SELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to enable the select() function in the "select" module (baremetal // implementation). This is present for compatibility but can be disabled to // save space. -#ifndef MICROPY_PY_USELECT_SELECT -#define MICROPY_PY_USELECT_SELECT (1) +#ifndef MICROPY_PY_SELECT_SELECT +#define MICROPY_PY_SELECT_SELECT (1) #endif // Whether to provide the "time" module -#ifndef MICROPY_PY_UTIME -#define MICROPY_PY_UTIME (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES) +#ifndef MICROPY_PY_TIME +#define MICROPY_PY_TIME (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES) #endif // Whether to provide time.gmtime/localtime/mktime functions -#ifndef MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME -#define MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME (0) +#ifndef MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME +#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (0) #endif // Whether to provide time.time/time_ns functions -#ifndef MICROPY_PY_UTIME_TIME_TIME_NS -#define MICROPY_PY_UTIME_TIME_TIME_NS (0) +#ifndef MICROPY_PY_TIME_TIME_TIME_NS +#define MICROPY_PY_TIME_TIME_TIME_NS (0) #endif // Period of values returned by time.ticks_ms(), ticks_us(), ticks_cpu() @@ -1501,8 +1501,8 @@ typedef double mp_float_t; // minimum of them should be used. The value below is the maximum value // this parameter can take (corresponding to 30 bit tick values on 32-bit // system). -#ifndef MICROPY_PY_UTIME_TICKS_PERIOD -#define MICROPY_PY_UTIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1) +#ifndef MICROPY_PY_TIME_TICKS_PERIOD +#define MICROPY_PY_TIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1) #endif // Whether to provide "_thread" module @@ -1538,101 +1538,101 @@ typedef double mp_float_t; #define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1) #endif -#ifndef MICROPY_PY_UZLIB -#define MICROPY_PY_UZLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_ZLIB +#define MICROPY_PY_ZLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -#ifndef MICROPY_PY_UJSON -#define MICROPY_PY_UJSON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_JSON +#define MICROPY_PY_JSON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support the "separators" argument to dump, dumps -#ifndef MICROPY_PY_UJSON_SEPARATORS -#define MICROPY_PY_UJSON_SEPARATORS (1) +#ifndef MICROPY_PY_JSON_SEPARATORS +#define MICROPY_PY_JSON_SEPARATORS (1) #endif -#ifndef MICROPY_PY_UOS -#define MICROPY_PY_UOS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_OS +#define MICROPY_PY_OS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -#ifndef MICROPY_PY_UOS_STATVFS -#define MICROPY_PY_UOS_STATVFS (MICROPY_PY_UOS) +#ifndef MICROPY_PY_OS_STATVFS +#define MICROPY_PY_OS_STATVFS (MICROPY_PY_OS) #endif -#ifndef MICROPY_PY_URE -#define MICROPY_PY_URE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_RE +#define MICROPY_PY_RE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -#ifndef MICROPY_PY_URE_DEBUG -#define MICROPY_PY_URE_DEBUG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) +#ifndef MICROPY_PY_RE_DEBUG +#define MICROPY_PY_RE_DEBUG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) #endif -#ifndef MICROPY_PY_URE_MATCH_GROUPS -#define MICROPY_PY_URE_MATCH_GROUPS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) +#ifndef MICROPY_PY_RE_MATCH_GROUPS +#define MICROPY_PY_RE_MATCH_GROUPS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) #endif -#ifndef MICROPY_PY_URE_MATCH_SPAN_START_END -#define MICROPY_PY_URE_MATCH_SPAN_START_END (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) +#ifndef MICROPY_PY_RE_MATCH_SPAN_START_END +#define MICROPY_PY_RE_MATCH_SPAN_START_END (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING) #endif -#ifndef MICROPY_PY_URE_SUB -#define MICROPY_PY_URE_SUB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_RE_SUB +#define MICROPY_PY_RE_SUB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -#ifndef MICROPY_PY_UHEAPQ -#define MICROPY_PY_UHEAPQ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_HEAPQ +#define MICROPY_PY_HEAPQ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Optimized heap queue for relative timestamps (only used by uasyncio v2) -#ifndef MICROPY_PY_UTIMEQ -#define MICROPY_PY_UTIMEQ (0) +#ifndef MICROPY_PY_TIMEQ +#define MICROPY_PY_TIMEQ (0) #endif -#ifndef MICROPY_PY_UHASHLIB -#define MICROPY_PY_UHASHLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_HASHLIB +#define MICROPY_PY_HASHLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -#ifndef MICROPY_PY_UHASHLIB_MD5 -#define MICROPY_PY_UHASHLIB_MD5 (0) +#ifndef MICROPY_PY_HASHLIB_MD5 +#define MICROPY_PY_HASHLIB_MD5 (0) #endif -#ifndef MICROPY_PY_UHASHLIB_SHA1 -#define MICROPY_PY_UHASHLIB_SHA1 (0) +#ifndef MICROPY_PY_HASHLIB_SHA1 +#define MICROPY_PY_HASHLIB_SHA1 (0) #endif -#ifndef MICROPY_PY_UHASHLIB_SHA256 -#define MICROPY_PY_UHASHLIB_SHA256 (1) +#ifndef MICROPY_PY_HASHLIB_SHA256 +#define MICROPY_PY_HASHLIB_SHA256 (1) #endif -#ifndef MICROPY_PY_UCRYPTOLIB -#define MICROPY_PY_UCRYPTOLIB (0) +#ifndef MICROPY_PY_CRYPTOLIB +#define MICROPY_PY_CRYPTOLIB (0) #endif -// Depends on MICROPY_PY_UCRYPTOLIB -#ifndef MICROPY_PY_UCRYPTOLIB_CTR -#define MICROPY_PY_UCRYPTOLIB_CTR (0) +// Depends on MICROPY_PY_CRYPTOLIB +#ifndef MICROPY_PY_CRYPTOLIB_CTR +#define MICROPY_PY_CRYPTOLIB_CTR (0) #endif -#ifndef MICROPY_PY_UCRYPTOLIB_CONSTS -#define MICROPY_PY_UCRYPTOLIB_CONSTS (0) +#ifndef MICROPY_PY_CRYPTOLIB_CONSTS +#define MICROPY_PY_CRYPTOLIB_CONSTS (0) #endif -#ifndef MICROPY_PY_UBINASCII -#define MICROPY_PY_UBINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_BINASCII +#define MICROPY_PY_BINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -// Depends on MICROPY_PY_UZLIB -#ifndef MICROPY_PY_UBINASCII_CRC32 -#define MICROPY_PY_UBINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +// Depends on MICROPY_PY_ZLIB +#ifndef MICROPY_PY_BINASCII_CRC32 +#define MICROPY_PY_BINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -#ifndef MICROPY_PY_URANDOM -#define MICROPY_PY_URANDOM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_RANDOM +#define MICROPY_PY_RANDOM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to include: randrange, randint, choice, random, uniform -#ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#ifndef MICROPY_PY_RANDOM_EXTRA_FUNCS +#define MICROPY_PY_RANDOM_EXTRA_FUNCS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_MACHINE @@ -1678,21 +1678,21 @@ typedef double mp_float_t; #endif // The default backlog value for socket.listen(backlog) -#ifndef MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT -#define MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT (2) +#ifndef MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT +#define MICROPY_PY_SOCKET_LISTEN_BACKLOG_DEFAULT (2) #endif -#ifndef MICROPY_PY_USSL -#define MICROPY_PY_USSL (0) +#ifndef MICROPY_PY_SSL +#define MICROPY_PY_SSL (0) #endif // Whether to add finaliser code to ssl objects -#ifndef MICROPY_PY_USSL_FINALISER -#define MICROPY_PY_USSL_FINALISER (0) +#ifndef MICROPY_PY_SSL_FINALISER +#define MICROPY_PY_SSL_FINALISER (0) #endif -#ifndef MICROPY_PY_UWEBSOCKET -#define MICROPY_PY_UWEBSOCKET (0) +#ifndef MICROPY_PY_WEBSOCKET +#define MICROPY_PY_WEBSOCKET (0) #endif #ifndef MICROPY_PY_FRAMEBUF diff --git a/py/mperrno.h b/py/mperrno.h index 6f6d816b8f4..be2a65a088c 100644 --- a/py/mperrno.h +++ b/py/mperrno.h @@ -141,7 +141,7 @@ #endif -#if MICROPY_PY_UERRNO +#if MICROPY_PY_ERRNO #include "py/obj.h" diff --git a/py/objbool.c b/py/objbool.c index 3267ff98bb8..96f0e60dd17 100644 --- a/py/objbool.c +++ b/py/objbool.c @@ -45,7 +45,7 @@ typedef struct _mp_obj_bool_t { STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { bool value = BOOL_VALUE(self_in); - if (MICROPY_PY_UJSON && kind == PRINT_JSON) { + if (MICROPY_PY_JSON && kind == PRINT_JSON) { if (value) { mp_print_str(print, "true"); } else { diff --git a/py/objdict.c b/py/objdict.c index a621c4feafb..8aafe607d69 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -75,10 +75,10 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ bool first = true; const char *item_separator = ", "; const char *key_separator = ": "; - if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { + if (!(MICROPY_PY_JSON && kind == PRINT_JSON)) { kind = PRINT_REPR; } else { - #if MICROPY_PY_UJSON_SEPARATORS + #if MICROPY_PY_JSON_SEPARATORS item_separator = MP_PRINT_GET_EXT(print)->item_separator; key_separator = MP_PRINT_GET_EXT(print)->key_separator; #endif @@ -94,7 +94,7 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ mp_print_str(print, item_separator); } first = false; - bool add_quote = MICROPY_PY_UJSON && kind == PRINT_JSON && !mp_obj_is_str_or_bytes(next->key); + bool add_quote = MICROPY_PY_JSON && kind == PRINT_JSON && !mp_obj_is_str_or_bytes(next->key); if (add_quote) { mp_print_str(print, "\""); } diff --git a/py/objexcept.c b/py/objexcept.c index cc0ddd9dc5f..a90405c5254 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -178,7 +178,7 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin return; } - #if MICROPY_PY_UERRNO + #if MICROPY_PY_ERRNO // try to provide a nice OSError error message if (o->base.type == &mp_type_OSError && o->args->len > 0 && o->args->len < 3 && mp_obj_is_small_int(o->args->items[0])) { qstr qst = mp_errno_to_str(o->args->items[0]); diff --git a/py/objlist.c b/py/objlist.c index 18da91ba3ab..1423cb1deeb 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -45,10 +45,10 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args); STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in); const char *item_separator = ", "; - if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { + if (!(MICROPY_PY_JSON && kind == PRINT_JSON)) { kind = PRINT_REPR; } else { - #if MICROPY_PY_UJSON_SEPARATORS + #if MICROPY_PY_JSON_SEPARATORS item_separator = MP_PRINT_GET_EXT(print)->item_separator; #endif } diff --git a/py/objnone.c b/py/objnone.c index 4b0696d3a14..5b25cd38c46 100644 --- a/py/objnone.c +++ b/py/objnone.c @@ -36,7 +36,7 @@ typedef struct _mp_obj_none_t { STATIC void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { (void)self_in; - if (MICROPY_PY_UJSON && kind == PRINT_JSON) { + if (MICROPY_PY_JSON && kind == PRINT_JSON) { mp_print_str(print, "null"); } else { mp_print_str(print, "None"); diff --git a/py/objstr.c b/py/objstr.c index e6c5ee71cf7..b966a70169c 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -109,7 +109,7 @@ void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t s mp_printf(print, "%c", quote_char); } -#if MICROPY_PY_UJSON +#if MICROPY_PY_JSON void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len) { // for JSON spec, see http://www.ietf.org/rfc/rfc4627.txt // if we are given a valid utf8-encoded string, we will print it in a JSON-conforming way @@ -137,7 +137,7 @@ void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { GET_STR_DATA_LEN(self_in, str_data, str_len); - #if MICROPY_PY_UJSON + #if MICROPY_PY_JSON if (kind == PRINT_JSON) { mp_str_print_json(print, str_data, str_len); return; diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 93383b3c19e..cbc797de291 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -85,7 +85,7 @@ STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { GET_STR_DATA_LEN(self_in, str_data, str_len); - #if MICROPY_PY_UJSON + #if MICROPY_PY_JSON if (kind == PRINT_JSON) { mp_str_print_json(print, str_data, str_len); return; diff --git a/py/objtuple.c b/py/objtuple.c index 9d6797b4ffc..0318a35db63 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -40,9 +40,9 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in); const char *item_separator = ", "; - if (MICROPY_PY_UJSON && kind == PRINT_JSON) { + if (MICROPY_PY_JSON && kind == PRINT_JSON) { mp_print_str(print, "["); - #if MICROPY_PY_UJSON_SEPARATORS + #if MICROPY_PY_JSON_SEPARATORS item_separator = MP_PRINT_GET_EXT(print)->item_separator; #endif } else { @@ -55,7 +55,7 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t } mp_obj_print_helper(print, o->items[i], kind); } - if (MICROPY_PY_UJSON && kind == PRINT_JSON) { + if (MICROPY_PY_JSON && kind == PRINT_JSON) { mp_print_str(print, "]"); } else { if (o->len == 1) { diff --git a/py/parse.c b/py/parse.c index a271aa0ea35..0dd56e4554f 100644 --- a/py/parse.c +++ b/py/parse.c @@ -636,7 +636,7 @@ STATIC void push_result_token(parser_t *parser, uint8_t rule_id) { #if MICROPY_COMP_MODULE_CONST STATIC const mp_rom_map_elem_t mp_constants_table[] = { - #if MICROPY_PY_UERRNO + #if MICROPY_PY_ERRNO { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_errno) }, #endif #if MICROPY_PY_UCTYPES diff --git a/tools/ci.sh b/tools/ci.sh index e8c4021f37e..8d361e2b397 100755 --- a/tools/ci.sh +++ b/tools/ci.sh @@ -395,14 +395,14 @@ function ci_teensy_build { CI_UNIX_OPTS_SYS_SETTRACE=( MICROPY_PY_BTREE=0 MICROPY_PY_FFI=0 - MICROPY_PY_USSL=0 + MICROPY_PY_SSL=0 CFLAGS_EXTRA="-DMICROPY_PY_SYS_SETTRACE=1" ) CI_UNIX_OPTS_SYS_SETTRACE_STACKLESS=( MICROPY_PY_BTREE=0 MICROPY_PY_FFI=0 - MICROPY_PY_USSL=0 + MICROPY_PY_SSL=0 CFLAGS_EXTRA="-DMICROPY_STACKLESS=1 -DMICROPY_STACKLESS_STRICT=1 -DMICROPY_PY_SYS_SETTRACE=1" ) From 0ceccd4cf809ef067feea8c42614b1bd07984451 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 18 Aug 2022 15:07:24 +1000 Subject: [PATCH 0013/4300] all: Rename *umodule*.h to remove the "u" prefix. This work was funded through GitHub Sponsors. Also updates #includes. Signed-off-by: Jim Mussared --- extmod/{moduplatform.h => modplatform.h} | 6 +++--- extmod/{modutime.h => modtime.h} | 0 extmod/moduplatform.c | 2 +- extmod/modutime.c | 2 +- extmod/moduwebsocket.c | 2 +- extmod/moduwebsocket.h | 10 ---------- extmod/modwebrepl.c | 2 +- extmod/modwebsocket.h | 10 ++++++++++ extmod/utime_mphal.h | 1 + ports/cc3200/ftp/ftp.c | 4 ++-- ports/cc3200/hal/cc3200_hal.c | 2 +- ports/cc3200/mods/modmachine.c | 2 +- ports/cc3200/mods/{moduos.h => modos.h} | 6 +++--- ports/cc3200/mods/{modusocket.h => modsocket.h} | 6 +++--- ports/cc3200/mods/moduos.c | 2 +- ports/cc3200/mods/modusocket.c | 2 +- ports/cc3200/mods/modussl.c | 2 +- ports/cc3200/mods/modwlan.c | 2 +- ports/cc3200/mods/pybuart.c | 2 +- ports/cc3200/mptask.c | 4 ++-- ports/cc3200/serverstask.c | 2 +- ports/cc3200/telnet/telnet.c | 2 +- ports/stm32/modpyb.c | 2 +- ports/unix/main.c | 2 +- py/modsys.c | 2 +- 25 files changed, 40 insertions(+), 39 deletions(-) rename extmod/{moduplatform.h => modplatform.h} (96%) rename extmod/{modutime.h => modtime.h} (100%) delete mode 100644 extmod/moduwebsocket.h create mode 100644 extmod/modwebsocket.h create mode 100644 extmod/utime_mphal.h rename ports/cc3200/mods/{moduos.h => modos.h} (92%) rename ports/cc3200/mods/{modusocket.h => modsocket.h} (91%) diff --git a/extmod/moduplatform.h b/extmod/modplatform.h similarity index 96% rename from extmod/moduplatform.h rename to extmod/modplatform.h index 7ca42977889..95bf073fbd9 100644 --- a/extmod/moduplatform.h +++ b/extmod/modplatform.h @@ -23,8 +23,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_MODUPLATFORM_H -#define MICROPY_INCLUDED_MODUPLATFORM_H +#ifndef MICROPY_INCLUDED_MODPLATFORM_H +#define MICROPY_INCLUDED_MODPLATFORM_H #include "py/misc.h" // For MP_STRINGIFY. #include "py/mpconfig.h" @@ -102,4 +102,4 @@ #define MICROPY_PLATFORM_VERSION "" #endif -#endif // MICROPY_INCLUDED_MODUPLATFORM_H +#endif // MICROPY_INCLUDED_MODPLATFORM_H diff --git a/extmod/modutime.h b/extmod/modtime.h similarity index 100% rename from extmod/modutime.h rename to extmod/modtime.h diff --git a/extmod/moduplatform.c b/extmod/moduplatform.c index d5f919fc5e0..4d10bdb4df0 100644 --- a/extmod/moduplatform.c +++ b/extmod/moduplatform.c @@ -29,7 +29,7 @@ #include "py/objtuple.h" #include "py/objstr.h" #include "py/mphal.h" -#include "extmod/moduplatform.h" +#include "extmod/modplatform.h" #include "genhdr/mpversion.h" #if MICROPY_PY_PLATFORM diff --git a/extmod/modutime.c b/extmod/modutime.c index 1dfd7aa2c09..163b874d5e0 100644 --- a/extmod/modutime.c +++ b/extmod/modutime.c @@ -28,7 +28,7 @@ #include "py/mphal.h" #include "py/runtime.h" #include "py/smallint.h" -#include "extmod/modutime.h" +#include "extmod/modtime.h" #if MICROPY_PY_TIME diff --git a/extmod/moduwebsocket.c b/extmod/moduwebsocket.c index ac90dea8b36..3bf50cc58c8 100644 --- a/extmod/moduwebsocket.c +++ b/extmod/moduwebsocket.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "py/stream.h" -#include "extmod/moduwebsocket.h" +#include "extmod/modwebsocket.h" #if MICROPY_PY_WEBSOCKET diff --git a/extmod/moduwebsocket.h b/extmod/moduwebsocket.h deleted file mode 100644 index c1ea291ed74..00000000000 --- a/extmod/moduwebsocket.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef MICROPY_INCLUDED_EXTMOD_MODUWEBSOCKET_H -#define MICROPY_INCLUDED_EXTMOD_MODUWEBSOCKET_H - -#define FRAME_OPCODE_MASK 0x0f -enum { - FRAME_CONT, FRAME_TXT, FRAME_BIN, - FRAME_CLOSE = 0x8, FRAME_PING, FRAME_PONG -}; - -#endif // MICROPY_INCLUDED_EXTMOD_MODUWEBSOCKET_H diff --git a/extmod/modwebrepl.c b/extmod/modwebrepl.c index d86f3589623..64276b5a8f3 100644 --- a/extmod/modwebrepl.c +++ b/extmod/modwebrepl.c @@ -34,7 +34,7 @@ #ifdef MICROPY_PY_WEBREPL_DELAY #include "py/mphal.h" #endif -#include "extmod/moduwebsocket.h" +#include "extmod/modwebsocket.h" #if MICROPY_PY_WEBREPL diff --git a/extmod/modwebsocket.h b/extmod/modwebsocket.h new file mode 100644 index 00000000000..2720147dfdb --- /dev/null +++ b/extmod/modwebsocket.h @@ -0,0 +1,10 @@ +#ifndef MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H +#define MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H + +#define FRAME_OPCODE_MASK 0x0f +enum { + FRAME_CONT, FRAME_TXT, FRAME_BIN, + FRAME_CLOSE = 0x8, FRAME_PING, FRAME_PONG +}; + +#endif // MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H diff --git a/extmod/utime_mphal.h b/extmod/utime_mphal.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/extmod/utime_mphal.h @@ -0,0 +1 @@ + diff --git a/ports/cc3200/ftp/ftp.c b/ports/cc3200/ftp/ftp.c index 173bb7c2c09..5d4fc6fb5f2 100644 --- a/ports/cc3200/ftp/ftp.c +++ b/ports/cc3200/ftp/ftp.c @@ -42,13 +42,13 @@ #include "simplelink.h" #include "modnetwork.h" #include "modwlan.h" -#include "modusocket.h" +#include "modsocket.h" #include "debug.h" #include "serverstask.h" #include "fifo.h" #include "socketfifo.h" #include "updater.h" -#include "moduos.h" +#include "modos.h" /****************************************************************************** DEFINE PRIVATE CONSTANTS diff --git a/ports/cc3200/hal/cc3200_hal.c b/ports/cc3200/hal/cc3200_hal.c index 4694235eebf..4d9d7647d3d 100644 --- a/ports/cc3200/hal/cc3200_hal.c +++ b/ports/cc3200/hal/cc3200_hal.c @@ -49,7 +49,7 @@ #include "pybuart.h" #include "utils.h" #include "irq.h" -#include "moduos.h" +#include "modos.h" #ifdef USE_FREERTOS #include "FreeRTOS.h" diff --git a/ports/cc3200/mods/modmachine.c b/ports/cc3200/mods/modmachine.c index c5b06f50777..a695fdccae2 100644 --- a/ports/cc3200/mods/modmachine.c +++ b/ports/cc3200/mods/modmachine.c @@ -43,7 +43,7 @@ #include "simplelink.h" #include "modnetwork.h" #include "modwlan.h" -#include "moduos.h" +#include "modos.h" #include "FreeRTOS.h" #include "portable.h" #include "task.h" diff --git a/ports/cc3200/mods/moduos.h b/ports/cc3200/mods/modos.h similarity index 92% rename from ports/cc3200/mods/moduos.h rename to ports/cc3200/mods/modos.h index f183715c907..5fa2a967d43 100644 --- a/ports/cc3200/mods/moduos.h +++ b/ports/cc3200/mods/modos.h @@ -24,8 +24,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_CC3200_MODS_MODUOS_H -#define MICROPY_INCLUDED_CC3200_MODS_MODUOS_H +#ifndef MICROPY_INCLUDED_CC3200_MODS_MODOS_H +#define MICROPY_INCLUDED_CC3200_MODS_MODOS_H #include "py/obj.h" @@ -44,4 +44,4 @@ typedef struct _os_term_dup_obj_t { ******************************************************************************/ void osmount_unmount_all (void); -#endif // MICROPY_INCLUDED_CC3200_MODS_MODUOS_H +#endif // MICROPY_INCLUDED_CC3200_MODS_MODOS_H diff --git a/ports/cc3200/mods/modusocket.h b/ports/cc3200/mods/modsocket.h similarity index 91% rename from ports/cc3200/mods/modusocket.h rename to ports/cc3200/mods/modsocket.h index aaee04ce192..8eb4cb50ac6 100644 --- a/ports/cc3200/mods/modusocket.h +++ b/ports/cc3200/mods/modsocket.h @@ -23,8 +23,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_CC3200_MODS_MODUSOCKET_H -#define MICROPY_INCLUDED_CC3200_MODS_MODUSOCKET_H +#ifndef MICROPY_INCLUDED_CC3200_MODS_MODSOCKET_H +#define MICROPY_INCLUDED_CC3200_MODS_MODSOCKET_H #include "py/stream.h" @@ -37,4 +37,4 @@ extern void modusocket_socket_delete (int16_t sd); extern void modusocket_enter_sleep (void); extern void modusocket_close_all_user_sockets (void); -#endif // MICROPY_INCLUDED_CC3200_MODS_MODUSOCKET_H +#endif // MICROPY_INCLUDED_CC3200_MODS_MODSOCKET_H diff --git a/ports/cc3200/mods/moduos.c b/ports/cc3200/mods/moduos.c index a6e4ef50a7a..7b1e8d79fd1 100644 --- a/ports/cc3200/mods/moduos.c +++ b/ports/cc3200/mods/moduos.c @@ -35,7 +35,7 @@ #include "lib/oofatfs/ff.h" #include "lib/oofatfs/diskio.h" #include "genhdr/mpversion.h" -#include "moduos.h" +#include "modos.h" #include "sflash_diskio.h" #include "extmod/vfs.h" #include "extmod/vfs_fat.h" diff --git a/ports/cc3200/mods/modusocket.c b/ports/cc3200/mods/modusocket.c index 9b614c6d34c..fd09cd6a413 100644 --- a/ports/cc3200/mods/modusocket.c +++ b/ports/cc3200/mods/modusocket.c @@ -37,7 +37,7 @@ #include "py/mphal.h" #include "shared/netutils/netutils.h" #include "modnetwork.h" -#include "modusocket.h" +#include "modsocket.h" /******************************************************************************/ // The following set of macros and functions provide a glue between the CC3100 diff --git a/ports/cc3200/mods/modussl.c b/ports/cc3200/mods/modussl.c index dda6725e668..eb3aea1f85b 100644 --- a/ports/cc3200/mods/modussl.c +++ b/ports/cc3200/mods/modussl.c @@ -32,7 +32,7 @@ #include "py/objstr.h" #include "py/runtime.h" #include "modnetwork.h" -#include "modusocket.h" +#include "modsocket.h" /****************************************************************************** DEFINE CONSTANTS diff --git a/ports/cc3200/mods/modwlan.c b/ports/cc3200/mods/modwlan.c index bf243ce7b9a..8d98dd0421d 100644 --- a/ports/cc3200/mods/modwlan.c +++ b/ports/cc3200/mods/modwlan.c @@ -38,7 +38,7 @@ #include "shared/timeutils/timeutils.h" #include "shared/netutils/netutils.h" #include "modnetwork.h" -#include "modusocket.h" +#include "modsocket.h" #include "modwlan.h" #include "pybrtc.h" #include "debug.h" diff --git a/ports/cc3200/mods/pybuart.c b/ports/cc3200/mods/pybuart.c index 424ca251ec7..5d6ad075275 100644 --- a/ports/cc3200/mods/pybuart.c +++ b/ports/cc3200/mods/pybuart.c @@ -50,7 +50,7 @@ #include "pin.h" #include "pybpin.h" #include "pins.h" -#include "moduos.h" +#include "modos.h" /// \moduleref pyb /// \class UART - duplex serial communication bus diff --git a/ports/cc3200/mptask.c b/ports/cc3200/mptask.c index a9dbf3c4c3e..abf8484b0d4 100644 --- a/ports/cc3200/mptask.c +++ b/ports/cc3200/mptask.c @@ -55,7 +55,7 @@ #include "mperror.h" #include "simplelink.h" #include "modnetwork.h" -#include "modusocket.h" +#include "modsocket.h" #include "modwlan.h" #include "serverstask.h" #include "telnet.h" @@ -70,7 +70,7 @@ #include "cryptohash.h" #include "mpirq.h" #include "updater.h" -#include "moduos.h" +#include "modos.h" #include "antenna.h" #include "task.h" diff --git a/ports/cc3200/serverstask.c b/ports/cc3200/serverstask.c index 4d852447f41..de782f5e7ac 100644 --- a/ports/cc3200/serverstask.c +++ b/ports/cc3200/serverstask.c @@ -37,7 +37,7 @@ #include "telnet.h" #include "ftp.h" #include "pybwdt.h" -#include "modusocket.h" +#include "modsocket.h" #include "modnetwork.h" #include "modwlan.h" diff --git a/ports/cc3200/telnet/telnet.c b/ports/cc3200/telnet/telnet.c index df1fd1c22d5..86843c78f6c 100644 --- a/ports/cc3200/telnet/telnet.c +++ b/ports/cc3200/telnet/telnet.c @@ -33,7 +33,7 @@ #include "simplelink.h" #include "modnetwork.h" #include "modwlan.h" -#include "modusocket.h" +#include "modsocket.h" #include "debug.h" #include "serverstask.h" #include "genhdr/mpversion.h" diff --git a/ports/stm32/modpyb.c b/ports/stm32/modpyb.c index b7d6fe7e6a1..831ece74a94 100644 --- a/ports/stm32/modpyb.c +++ b/ports/stm32/modpyb.c @@ -54,7 +54,7 @@ #include "modmachine.h" #include "extmod/modnetwork.h" #include "extmod/vfs.h" -#include "extmod/modutime.h" +#include "extmod/modtime.h" #if MICROPY_PY_PYB diff --git a/ports/unix/main.c b/ports/unix/main.c index 392ce59dded..16f663de199 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -48,7 +48,7 @@ #include "py/mphal.h" #include "py/mpthread.h" #include "extmod/misc.h" -#include "extmod/moduplatform.h" +#include "extmod/modplatform.h" #include "extmod/vfs.h" #include "extmod/vfs_posix.h" #include "genhdr/mpversion.h" diff --git a/py/modsys.c b/py/modsys.c index 09bdfefc634..1cfc09ecfbf 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -36,7 +36,7 @@ #include "py/smallint.h" #include "py/runtime.h" #include "py/persistentcode.h" -#include "extmod/moduplatform.h" +#include "extmod/modplatform.h" #include "genhdr/mpversion.h" #if MICROPY_PY_SYS_SETTRACE From 45ac651d1a2801bccbdc32fddaa9b029ed4ce879 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 18 Aug 2022 16:24:27 +1000 Subject: [PATCH 0014/4300] all: Rename *umodule*.c to remove the "u" prefix. Updates any includes, and references from Makefiles/CMake. This essentially reverts what was done long ago in commit 136b5cbd7669e8318f8455fc2706da97a5b7994c This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- .../embedding/Makefile.upylib | 0 examples/natmod/uheapq/uheapq.c | 2 +- examples/natmod/urandom/urandom.c | 2 +- examples/natmod/ure/ure.c | 2 +- examples/natmod/uzlib/uzlib.c | 2 +- extmod/extmod.cmake | 36 +++++++++---------- extmod/extmod.mk | 36 +++++++++---------- extmod/{modubinascii.c => modbinascii.c} | 0 extmod/{moducryptolib.c => modcryptolib.c} | 0 extmod/{moduhashlib.c => modhashlib.c} | 0 extmod/{moduheapq.c => modheapq.c} | 0 extmod/{modujson.c => modjson.c} | 0 extmod/modlwip.c | 2 +- extmod/{moduos.c => modos.c} | 0 extmod/{moduplatform.c => modplatform.c} | 0 extmod/{modurandom.c => modrandom.c} | 0 extmod/{modure.c => modre.c} | 0 extmod/{moduselect.c => modselect.c} | 0 extmod/{modusocket.c => modsocket.c} | 0 extmod/{modussl_axtls.c => modssl_axtls.c} | 0 .../{modussl_mbedtls.c => modssl_mbedtls.c} | 0 extmod/{modutime.c => modtime.c} | 0 extmod/{modutimeq.c => modtimeq.c} | 0 extmod/{moduwebsocket.c => modwebsocket.c} | 0 extmod/{moduzlib.c => modzlib.c} | 0 extmod/{uos_dupterm.c => os_dupterm.c} | 0 ports/cc3200/application.mk | 6 ++-- .../mods/{moduhashlib.c => modhashlib.c} | 0 ports/cc3200/mods/{moduos.c => modos.c} | 0 .../cc3200/mods/{modusocket.c => modsocket.c} | 0 ports/cc3200/mods/{modussl.c => modssl.c} | 0 ports/cc3200/mods/{modutime.c => modtime.c} | 0 ports/embed/embed.mk | 2 +- ports/esp32/{moduos.c => modos.c} | 0 ports/esp32/{modutime.c => modtime.c} | 0 ports/esp32/mpconfigport.h | 2 +- ports/esp8266/boards/esp8266_common.ld | 2 +- ports/esp8266/{moduos.c => modos.c} | 0 ports/esp8266/{modutime.c => modtime.c} | 0 ports/esp8266/mpconfigport.h | 2 +- ports/mimxrt/{moduos.c => modos.c} | 0 ports/mimxrt/{modutime.c => modtime.c} | 0 ports/mimxrt/mpconfigport.h | 4 +-- ports/nrf/Makefile | 4 +-- ports/nrf/modules/{uos => os}/microbitfs.c | 0 ports/nrf/modules/{uos => os}/microbitfs.h | 0 .../nrf/modules/{uos/moduos.c => os/modos.c} | 0 ports/renesas-ra/{moduos.c => modos.c} | 0 ports/renesas-ra/{modutime.c => modtime.c} | 0 ports/renesas-ra/mpconfigport.h | 2 +- ports/rp2/CMakeLists.txt | 2 +- ports/rp2/{moduos.c => modos.c} | 0 ports/rp2/{modutime.c => modtime.c} | 0 ports/rp2/mpconfigport.h | 4 +-- ports/samd/{moduos.c => modos.c} | 0 ports/samd/{modutime.c => modtime.c} | 0 ports/stm32/{moduos.c => modos.c} | 0 ports/stm32/{modutime.c => modtime.c} | 0 ports/stm32/mpconfigport.h | 4 +-- ports/unix/Makefile | 4 +-- ports/unix/{moduos.c => modos.c} | 0 ports/unix/{moduselect.c => modselect.c} | 0 ports/unix/{modusocket.c => modsocket.c} | 0 ports/unix/{modutime.c => modtime.c} | 0 ports/unix/variants/mpconfigvariant_common.h | 4 +-- ports/windows/mpconfigport.h | 4 +-- ports/windows/msvc/sources.props | 22 ++++++------ ports/zephyr/CMakeLists.txt | 2 +- ports/zephyr/{modusocket.c => modsocket.c} | 0 ports/zephyr/{modutime.c => modtime.c} | 0 ports/zephyr/mpconfigport.h | 2 +- py/{moduerrno.c => moderrno.c} | 0 py/py.cmake | 2 +- py/py.mk | 2 +- tools/codeformat.py | 4 +-- 75 files changed, 81 insertions(+), 81 deletions(-) rename extmod/utime_mphal.c => examples/embedding/Makefile.upylib (100%) rename extmod/{modubinascii.c => modbinascii.c} (100%) rename extmod/{moducryptolib.c => modcryptolib.c} (100%) rename extmod/{moduhashlib.c => modhashlib.c} (100%) rename extmod/{moduheapq.c => modheapq.c} (100%) rename extmod/{modujson.c => modjson.c} (100%) rename extmod/{moduos.c => modos.c} (100%) rename extmod/{moduplatform.c => modplatform.c} (100%) rename extmod/{modurandom.c => modrandom.c} (100%) rename extmod/{modure.c => modre.c} (100%) rename extmod/{moduselect.c => modselect.c} (100%) rename extmod/{modusocket.c => modsocket.c} (100%) rename extmod/{modussl_axtls.c => modssl_axtls.c} (100%) rename extmod/{modussl_mbedtls.c => modssl_mbedtls.c} (100%) rename extmod/{modutime.c => modtime.c} (100%) rename extmod/{modutimeq.c => modtimeq.c} (100%) rename extmod/{moduwebsocket.c => modwebsocket.c} (100%) rename extmod/{moduzlib.c => modzlib.c} (100%) rename extmod/{uos_dupterm.c => os_dupterm.c} (100%) rename ports/cc3200/mods/{moduhashlib.c => modhashlib.c} (100%) rename ports/cc3200/mods/{moduos.c => modos.c} (100%) rename ports/cc3200/mods/{modusocket.c => modsocket.c} (100%) rename ports/cc3200/mods/{modussl.c => modssl.c} (100%) rename ports/cc3200/mods/{modutime.c => modtime.c} (100%) rename ports/esp32/{moduos.c => modos.c} (100%) rename ports/esp32/{modutime.c => modtime.c} (100%) rename ports/esp8266/{moduos.c => modos.c} (100%) rename ports/esp8266/{modutime.c => modtime.c} (100%) rename ports/mimxrt/{moduos.c => modos.c} (100%) rename ports/mimxrt/{modutime.c => modtime.c} (100%) rename ports/nrf/modules/{uos => os}/microbitfs.c (100%) rename ports/nrf/modules/{uos => os}/microbitfs.h (100%) rename ports/nrf/modules/{uos/moduos.c => os/modos.c} (100%) rename ports/renesas-ra/{moduos.c => modos.c} (100%) rename ports/renesas-ra/{modutime.c => modtime.c} (100%) rename ports/rp2/{moduos.c => modos.c} (100%) rename ports/rp2/{modutime.c => modtime.c} (100%) rename ports/samd/{moduos.c => modos.c} (100%) rename ports/samd/{modutime.c => modtime.c} (100%) rename ports/stm32/{moduos.c => modos.c} (100%) rename ports/stm32/{modutime.c => modtime.c} (100%) rename ports/unix/{moduos.c => modos.c} (100%) rename ports/unix/{moduselect.c => modselect.c} (100%) rename ports/unix/{modusocket.c => modsocket.c} (100%) rename ports/unix/{modutime.c => modtime.c} (100%) rename ports/zephyr/{modusocket.c => modsocket.c} (100%) rename ports/zephyr/{modutime.c => modtime.c} (100%) rename py/{moduerrno.c => moderrno.c} (100%) diff --git a/extmod/utime_mphal.c b/examples/embedding/Makefile.upylib similarity index 100% rename from extmod/utime_mphal.c rename to examples/embedding/Makefile.upylib diff --git a/examples/natmod/uheapq/uheapq.c b/examples/natmod/uheapq/uheapq.c index e339ccafd77..ed19652a66b 100644 --- a/examples/natmod/uheapq/uheapq.c +++ b/examples/natmod/uheapq/uheapq.c @@ -2,7 +2,7 @@ #include "py/dynruntime.h" -#include "extmod/moduheapq.c" +#include "extmod/modheapq.c" mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) { MP_DYNRUNTIME_INIT_ENTRY diff --git a/examples/natmod/urandom/urandom.c b/examples/natmod/urandom/urandom.c index ed46651b342..92257b8bc68 100644 --- a/examples/natmod/urandom/urandom.c +++ b/examples/natmod/urandom/urandom.c @@ -7,7 +7,7 @@ uint32_t yasmarang_pad, yasmarang_n, yasmarang_d; uint8_t yasmarang_dat; -#include "extmod/modurandom.c" +#include "extmod/modrandom.c" mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) { MP_DYNRUNTIME_INIT_ENTRY diff --git a/examples/natmod/ure/ure.c b/examples/natmod/ure/ure.c index 79eca90ab9e..df89ea83530 100644 --- a/examples/natmod/ure/ure.c +++ b/examples/natmod/ure/ure.c @@ -35,7 +35,7 @@ void *memmove(void *dest, const void *src, size_t n) { mp_obj_full_type_t match_type; mp_obj_full_type_t re_type; -#include "extmod/modure.c" +#include "extmod/modre.c" mp_map_elem_t match_locals_dict_table[5]; STATIC MP_DEFINE_CONST_DICT(match_locals_dict, match_locals_dict_table); diff --git a/examples/natmod/uzlib/uzlib.c b/examples/natmod/uzlib/uzlib.c index 9a3ec0af3c8..2b0dbd5ca01 100644 --- a/examples/natmod/uzlib/uzlib.c +++ b/examples/natmod/uzlib/uzlib.c @@ -10,7 +10,7 @@ void *memset(void *s, int c, size_t n) { mp_obj_full_type_t decompio_type; -#include "extmod/moduzlib.c" +#include "extmod/modzlib.c" mp_map_elem_t decompio_locals_dict_table[3]; STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table); diff --git a/extmod/extmod.cmake b/extmod/extmod.cmake index 675a4c6eccf..2bb89423c9a 100644 --- a/extmod/extmod.cmake +++ b/extmod/extmod.cmake @@ -19,30 +19,30 @@ set(MICROPY_SOURCE_EXTMOD ${MICROPY_EXTMOD_DIR}/modnetwork.c ${MICROPY_EXTMOD_DIR}/modonewire.c ${MICROPY_EXTMOD_DIR}/moduasyncio.c - ${MICROPY_EXTMOD_DIR}/modubinascii.c - ${MICROPY_EXTMOD_DIR}/moducryptolib.c + ${MICROPY_EXTMOD_DIR}/modbinascii.c + ${MICROPY_EXTMOD_DIR}/modcryptolib.c ${MICROPY_EXTMOD_DIR}/moductypes.c - ${MICROPY_EXTMOD_DIR}/moduhashlib.c - ${MICROPY_EXTMOD_DIR}/moduheapq.c - ${MICROPY_EXTMOD_DIR}/modujson.c - ${MICROPY_EXTMOD_DIR}/moduos.c - ${MICROPY_EXTMOD_DIR}/moduplatform.c - ${MICROPY_EXTMOD_DIR}/modurandom.c - ${MICROPY_EXTMOD_DIR}/modure.c - ${MICROPY_EXTMOD_DIR}/moduselect.c - ${MICROPY_EXTMOD_DIR}/modusocket.c - ${MICROPY_EXTMOD_DIR}/modussl_axtls.c - ${MICROPY_EXTMOD_DIR}/modussl_mbedtls.c - ${MICROPY_EXTMOD_DIR}/modutime.c - ${MICROPY_EXTMOD_DIR}/modutimeq.c - ${MICROPY_EXTMOD_DIR}/moduwebsocket.c - ${MICROPY_EXTMOD_DIR}/moduzlib.c + ${MICROPY_EXTMOD_DIR}/modhashlib.c + ${MICROPY_EXTMOD_DIR}/modheapq.c + ${MICROPY_EXTMOD_DIR}/modjson.c + ${MICROPY_EXTMOD_DIR}/modos.c + ${MICROPY_EXTMOD_DIR}/modplatform.c + ${MICROPY_EXTMOD_DIR}/modrandom.c + ${MICROPY_EXTMOD_DIR}/modre.c + ${MICROPY_EXTMOD_DIR}/modselect.c + ${MICROPY_EXTMOD_DIR}/modsocket.c + ${MICROPY_EXTMOD_DIR}/modssl_axtls.c + ${MICROPY_EXTMOD_DIR}/modssl_mbedtls.c + ${MICROPY_EXTMOD_DIR}/modtime.c + ${MICROPY_EXTMOD_DIR}/modtimeq.c + ${MICROPY_EXTMOD_DIR}/modwebsocket.c + ${MICROPY_EXTMOD_DIR}/modzlib.c ${MICROPY_EXTMOD_DIR}/modwebrepl.c ${MICROPY_EXTMOD_DIR}/network_cyw43.c ${MICROPY_EXTMOD_DIR}/network_lwip.c ${MICROPY_EXTMOD_DIR}/network_ninaw10.c ${MICROPY_EXTMOD_DIR}/network_wiznet5k.c - ${MICROPY_EXTMOD_DIR}/uos_dupterm.c + ${MICROPY_EXTMOD_DIR}/os_dupterm.c ${MICROPY_EXTMOD_DIR}/vfs.c ${MICROPY_EXTMOD_DIR}/vfs_blockdev.c ${MICROPY_EXTMOD_DIR}/vfs_fat.c diff --git a/extmod/extmod.mk b/extmod/extmod.mk index 2f9bd3b065d..a573da4c60a 100644 --- a/extmod/extmod.mk +++ b/extmod/extmod.mk @@ -11,37 +11,37 @@ SRC_EXTMOD_C += \ extmod/machine_signal.c \ extmod/machine_spi.c \ extmod/machine_timer.c \ + extmod/modbinascii.c \ extmod/modbluetooth.c \ extmod/modbtree.c \ + extmod/modcryptolib.c \ extmod/modframebuf.c \ + extmod/modhashlib.c \ + extmod/modheapq.c \ + extmod/modjson.c \ extmod/modlwip.c \ extmod/modnetwork.c \ extmod/modonewire.c \ + extmod/modos.c \ + extmod/modplatform.c\ + extmod/modrandom.c \ + extmod/modre.c \ + extmod/modselect.c \ + extmod/modsocket.c \ + extmod/modssl_axtls.c \ + extmod/modssl_mbedtls.c \ + extmod/modtime.c \ + extmod/modtimeq.c \ extmod/moduasyncio.c \ - extmod/modubinascii.c \ - extmod/moducryptolib.c \ extmod/moductypes.c \ - extmod/moduhashlib.c \ - extmod/moduheapq.c \ - extmod/modujson.c \ - extmod/moduos.c \ - extmod/moduplatform.c\ - extmod/modurandom.c \ - extmod/modure.c \ - extmod/moduselect.c \ - extmod/modusocket.c \ - extmod/modussl_axtls.c \ - extmod/modussl_mbedtls.c \ - extmod/modutime.c \ - extmod/modutimeq.c \ - extmod/moduwebsocket.c \ - extmod/moduzlib.c \ extmod/modwebrepl.c \ + extmod/modwebsocket.c \ + extmod/modzlib.c \ extmod/network_cyw43.c \ extmod/network_lwip.c \ extmod/network_ninaw10.c \ extmod/network_wiznet5k.c \ - extmod/uos_dupterm.c \ + extmod/os_dupterm.c \ extmod/vfs.c \ extmod/vfs_blockdev.c \ extmod/vfs_fat.c \ diff --git a/extmod/modubinascii.c b/extmod/modbinascii.c similarity index 100% rename from extmod/modubinascii.c rename to extmod/modbinascii.c diff --git a/extmod/moducryptolib.c b/extmod/modcryptolib.c similarity index 100% rename from extmod/moducryptolib.c rename to extmod/modcryptolib.c diff --git a/extmod/moduhashlib.c b/extmod/modhashlib.c similarity index 100% rename from extmod/moduhashlib.c rename to extmod/modhashlib.c diff --git a/extmod/moduheapq.c b/extmod/modheapq.c similarity index 100% rename from extmod/moduheapq.c rename to extmod/modheapq.c diff --git a/extmod/modujson.c b/extmod/modjson.c similarity index 100% rename from extmod/modujson.c rename to extmod/modjson.c diff --git a/extmod/modlwip.c b/extmod/modlwip.c index a902e8fb0fe..24047b0a98c 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -1801,7 +1801,7 @@ const mp_obj_module_t mp_module_lwip = { MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip); -// On LWIP-ports, this is the socket module (replaces extmod/modusocket.c). +// On LWIP-ports, this is the socket module (replaces extmod/modsocket.c). MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_lwip); MP_REGISTER_ROOT_POINTER(mp_obj_t lwip_slip_stream); diff --git a/extmod/moduos.c b/extmod/modos.c similarity index 100% rename from extmod/moduos.c rename to extmod/modos.c diff --git a/extmod/moduplatform.c b/extmod/modplatform.c similarity index 100% rename from extmod/moduplatform.c rename to extmod/modplatform.c diff --git a/extmod/modurandom.c b/extmod/modrandom.c similarity index 100% rename from extmod/modurandom.c rename to extmod/modrandom.c diff --git a/extmod/modure.c b/extmod/modre.c similarity index 100% rename from extmod/modure.c rename to extmod/modre.c diff --git a/extmod/moduselect.c b/extmod/modselect.c similarity index 100% rename from extmod/moduselect.c rename to extmod/modselect.c diff --git a/extmod/modusocket.c b/extmod/modsocket.c similarity index 100% rename from extmod/modusocket.c rename to extmod/modsocket.c diff --git a/extmod/modussl_axtls.c b/extmod/modssl_axtls.c similarity index 100% rename from extmod/modussl_axtls.c rename to extmod/modssl_axtls.c diff --git a/extmod/modussl_mbedtls.c b/extmod/modssl_mbedtls.c similarity index 100% rename from extmod/modussl_mbedtls.c rename to extmod/modssl_mbedtls.c diff --git a/extmod/modutime.c b/extmod/modtime.c similarity index 100% rename from extmod/modutime.c rename to extmod/modtime.c diff --git a/extmod/modutimeq.c b/extmod/modtimeq.c similarity index 100% rename from extmod/modutimeq.c rename to extmod/modtimeq.c diff --git a/extmod/moduwebsocket.c b/extmod/modwebsocket.c similarity index 100% rename from extmod/moduwebsocket.c rename to extmod/modwebsocket.c diff --git a/extmod/moduzlib.c b/extmod/modzlib.c similarity index 100% rename from extmod/moduzlib.c rename to extmod/modzlib.c diff --git a/extmod/uos_dupterm.c b/extmod/os_dupterm.c similarity index 100% rename from extmod/uos_dupterm.c rename to extmod/os_dupterm.c diff --git a/ports/cc3200/application.mk b/ports/cc3200/application.mk index 78c2b8044a1..5021e4ff3cb 100644 --- a/ports/cc3200/application.mk +++ b/ports/cc3200/application.mk @@ -78,9 +78,9 @@ APP_MISC_SRC_C = $(addprefix misc/,\ APP_MODS_SRC_C = $(addprefix mods/,\ modmachine.c \ modnetwork.c \ - moduos.c \ - modusocket.c \ - modussl.c \ + modos.c \ + modsocket.c \ + modssl.c \ modwipy.c \ modwlan.c \ pybadc.c \ diff --git a/ports/cc3200/mods/moduhashlib.c b/ports/cc3200/mods/modhashlib.c similarity index 100% rename from ports/cc3200/mods/moduhashlib.c rename to ports/cc3200/mods/modhashlib.c diff --git a/ports/cc3200/mods/moduos.c b/ports/cc3200/mods/modos.c similarity index 100% rename from ports/cc3200/mods/moduos.c rename to ports/cc3200/mods/modos.c diff --git a/ports/cc3200/mods/modusocket.c b/ports/cc3200/mods/modsocket.c similarity index 100% rename from ports/cc3200/mods/modusocket.c rename to ports/cc3200/mods/modsocket.c diff --git a/ports/cc3200/mods/modussl.c b/ports/cc3200/mods/modssl.c similarity index 100% rename from ports/cc3200/mods/modussl.c rename to ports/cc3200/mods/modssl.c diff --git a/ports/cc3200/mods/modutime.c b/ports/cc3200/mods/modtime.c similarity index 100% rename from ports/cc3200/mods/modutime.c rename to ports/cc3200/mods/modtime.c diff --git a/ports/embed/embed.mk b/ports/embed/embed.mk index 7fb344d7049..84d45accd2d 100644 --- a/ports/embed/embed.mk +++ b/ports/embed/embed.mk @@ -52,7 +52,7 @@ micropython-embed-package: $(GENHDR_OUTPUT) $(ECHO) "- py" $(Q)$(CP) $(TOP)/py/*.[ch] $(PACKAGE_DIR)/py $(ECHO) "- extmod" - $(Q)$(CP) $(TOP)/extmod/moduplatform.h $(PACKAGE_DIR)/extmod + $(Q)$(CP) $(TOP)/extmod/modplatform.h $(PACKAGE_DIR)/extmod $(ECHO) "- shared" $(Q)$(CP) $(TOP)/shared/runtime/gchelper.h $(PACKAGE_DIR)/shared/runtime $(Q)$(CP) $(TOP)/shared/runtime/gchelper_generic.c $(PACKAGE_DIR)/shared/runtime diff --git a/ports/esp32/moduos.c b/ports/esp32/modos.c similarity index 100% rename from ports/esp32/moduos.c rename to ports/esp32/modos.c diff --git a/ports/esp32/modutime.c b/ports/esp32/modtime.c similarity index 100% rename from ports/esp32/modutime.c rename to ports/esp32/modtime.c diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index d25a5c2734d..217a9ec2974 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -88,7 +88,7 @@ #define MICROPY_PY_HASHLIB_SHA256 (1) #define MICROPY_PY_CRYPTOLIB (1) #define MICROPY_PY_RANDOM_SEED_INIT_FUNC (esp_random()) -#define MICROPY_PY_OS_INCLUDEFILE "ports/esp32/moduos.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/esp32/modos.c" #define MICROPY_PY_OS_DUPTERM (1) #define MICROPY_PY_OS_DUPTERM_NOTIFY (1) #define MICROPY_PY_OS_SYNC (1) diff --git a/ports/esp8266/boards/esp8266_common.ld b/ports/esp8266/boards/esp8266_common.ld index 7e230fd42a6..083e84d9afe 100644 --- a/ports/esp8266/boards/esp8266_common.ld +++ b/ports/esp8266/boards/esp8266_common.ld @@ -164,7 +164,7 @@ SECTIONS *machine_hspi.o(.literal*, .text*) *hspi.o(.literal*, .text*) *modesp.o(.literal* .text*) - *moduos.o(.literal* .text*) + *modos.o(.literal* .text*) *modlwip.o(.literal* .text*) *modsocket.o(.literal* .text*) *modonewire.o(.literal* .text*) diff --git a/ports/esp8266/moduos.c b/ports/esp8266/modos.c similarity index 100% rename from ports/esp8266/moduos.c rename to ports/esp8266/modos.c diff --git a/ports/esp8266/modutime.c b/ports/esp8266/modtime.c similarity index 100% rename from ports/esp8266/modutime.c rename to ports/esp8266/modtime.c diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h index 9985d59dd39..37a794f44b2 100644 --- a/ports/esp8266/mpconfigport.h +++ b/ports/esp8266/mpconfigport.h @@ -58,7 +58,7 @@ #define MICROPY_PY_RANDOM_SEED_INIT_FUNC (*WDEV_HWRNG) #define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) #define MICROPY_PY_TIME_TIME_TIME_NS (1) -#define MICROPY_PY_TIME_INCLUDEFILE "ports/esp8266/modutime.c" +#define MICROPY_PY_TIME_INCLUDEFILE "ports/esp8266/modtime.c" #define MICROPY_PY_LWIP (1) #define MICROPY_PY_LWIP_SOCK_RAW (1) #define MICROPY_PY_MACHINE (1) diff --git a/ports/mimxrt/moduos.c b/ports/mimxrt/modos.c similarity index 100% rename from ports/mimxrt/moduos.c rename to ports/mimxrt/modos.c diff --git a/ports/mimxrt/modutime.c b/ports/mimxrt/modtime.c similarity index 100% rename from ports/mimxrt/modutime.c rename to ports/mimxrt/modtime.c diff --git a/ports/mimxrt/mpconfigport.h b/ports/mimxrt/mpconfigport.h index be086cb5521..b1cd84f2656 100644 --- a/ports/mimxrt/mpconfigport.h +++ b/ports/mimxrt/mpconfigport.h @@ -72,8 +72,8 @@ uint32_t trng_random_u32(void); #define MICROPY_PY_SSL_FINALISER (MICROPY_PY_SSL) #define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) #define MICROPY_PY_TIME_TIME_TIME_NS (1) -#define MICROPY_PY_TIME_INCLUDEFILE "ports/mimxrt/modutime.c" -#define MICROPY_PY_OS_INCLUDEFILE "ports/mimxrt/moduos.c" +#define MICROPY_PY_TIME_INCLUDEFILE "ports/mimxrt/modtime.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/mimxrt/modos.c" #define MICROPY_PY_OS_DUPTERM (3) #define MICROPY_PY_OS_DUPTERM_NOTIFY (1) #define MICROPY_PY_OS_SYNC (1) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 54701adacb3..89bb03dfae2 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -329,8 +329,8 @@ DRIVERS_SRC_C += $(addprefix modules/,\ machine/timer.c \ machine/rtcounter.c \ machine/temp.c \ - uos/moduos.c \ - uos/microbitfs.c \ + os/modos.c \ + os/microbitfs.c \ board/modboard.c \ board/led.c \ ubluepy/modubluepy.c \ diff --git a/ports/nrf/modules/uos/microbitfs.c b/ports/nrf/modules/os/microbitfs.c similarity index 100% rename from ports/nrf/modules/uos/microbitfs.c rename to ports/nrf/modules/os/microbitfs.c diff --git a/ports/nrf/modules/uos/microbitfs.h b/ports/nrf/modules/os/microbitfs.h similarity index 100% rename from ports/nrf/modules/uos/microbitfs.h rename to ports/nrf/modules/os/microbitfs.h diff --git a/ports/nrf/modules/uos/moduos.c b/ports/nrf/modules/os/modos.c similarity index 100% rename from ports/nrf/modules/uos/moduos.c rename to ports/nrf/modules/os/modos.c diff --git a/ports/renesas-ra/moduos.c b/ports/renesas-ra/modos.c similarity index 100% rename from ports/renesas-ra/moduos.c rename to ports/renesas-ra/modos.c diff --git a/ports/renesas-ra/modutime.c b/ports/renesas-ra/modtime.c similarity index 100% rename from ports/renesas-ra/modutime.c rename to ports/renesas-ra/modtime.c diff --git a/ports/renesas-ra/mpconfigport.h b/ports/renesas-ra/mpconfigport.h index 1886d31541a..42ce0b68272 100644 --- a/ports/renesas-ra/mpconfigport.h +++ b/ports/renesas-ra/mpconfigport.h @@ -91,7 +91,7 @@ #endif // extended modules -#define MICROPY_PY_OS_INCLUDEFILE "ports/renesas-ra/moduos.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/renesas-ra/modos.c" #define MICROPY_PY_OS_DUPTERM (3) #define MICROPY_PY_OS_DUPTERM_BUILTIN_STREAM (1) #define MICROPY_PY_OS_DUPTERM_STREAM_DETACHED_ATTACHED (1) diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt index 3dff0d54c6a..55c542173ab 100644 --- a/ports/rp2/CMakeLists.txt +++ b/ports/rp2/CMakeLists.txt @@ -157,7 +157,7 @@ set(MICROPY_SOURCE_QSTR ${PROJECT_SOURCE_DIR}/machine_wdt.c ${PROJECT_SOURCE_DIR}/modmachine.c ${PROJECT_SOURCE_DIR}/modrp2.c - ${PROJECT_SOURCE_DIR}/moduos.c + ${PROJECT_SOURCE_DIR}/modos.c ${PROJECT_SOURCE_DIR}/rp2_flash.c ${PROJECT_SOURCE_DIR}/rp2_pio.c ${CMAKE_BINARY_DIR}/pins_${MICROPY_BOARD}.c diff --git a/ports/rp2/moduos.c b/ports/rp2/modos.c similarity index 100% rename from ports/rp2/moduos.c rename to ports/rp2/modos.c diff --git a/ports/rp2/modutime.c b/ports/rp2/modtime.c similarity index 100% rename from ports/rp2/modutime.c rename to ports/rp2/modtime.c diff --git a/ports/rp2/mpconfigport.h b/ports/rp2/mpconfigport.h index de05a281bdb..28b06fa3a8f 100644 --- a/ports/rp2/mpconfigport.h +++ b/ports/rp2/mpconfigport.h @@ -95,7 +95,7 @@ // Extended modules #define MICROPY_EPOCH_IS_1970 (1) -#define MICROPY_PY_OS_INCLUDEFILE "ports/rp2/moduos.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/rp2/modos.c" #ifndef MICROPY_PY_OS_DUPTERM #define MICROPY_PY_OS_DUPTERM (1) #endif @@ -108,7 +108,7 @@ #define MICROPY_PY_CRYPTOLIB (1) #define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) #define MICROPY_PY_TIME_TIME_TIME_NS (1) -#define MICROPY_PY_TIME_INCLUDEFILE "ports/rp2/modutime.c" +#define MICROPY_PY_TIME_INCLUDEFILE "ports/rp2/modtime.c" #define MICROPY_PY_RANDOM_SEED_INIT_FUNC (rosc_random_u32()) #define MICROPY_PY_MACHINE (1) #define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new diff --git a/ports/samd/moduos.c b/ports/samd/modos.c similarity index 100% rename from ports/samd/moduos.c rename to ports/samd/modos.c diff --git a/ports/samd/modutime.c b/ports/samd/modtime.c similarity index 100% rename from ports/samd/modutime.c rename to ports/samd/modtime.c diff --git a/ports/stm32/moduos.c b/ports/stm32/modos.c similarity index 100% rename from ports/stm32/moduos.c rename to ports/stm32/modos.c diff --git a/ports/stm32/modutime.c b/ports/stm32/modtime.c similarity index 100% rename from ports/stm32/modutime.c rename to ports/stm32/modtime.c diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index 49a8a034052..c0a95cf5d56 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -96,7 +96,7 @@ #define MICROPY_PY_HASHLIB_MD5 (MICROPY_PY_SSL) #define MICROPY_PY_HASHLIB_SHA1 (MICROPY_PY_SSL) #define MICROPY_PY_CRYPTOLIB (MICROPY_PY_SSL) -#define MICROPY_PY_OS_INCLUDEFILE "ports/stm32/moduos.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/stm32/modos.c" #define MICROPY_PY_OS_DUPTERM (3) #define MICROPY_PY_OS_DUPTERM_BUILTIN_STREAM (1) #define MICROPY_PY_OS_DUPTERM_STREAM_DETACHED_ATTACHED (1) @@ -107,7 +107,7 @@ #define MICROPY_PY_RANDOM_SEED_INIT_FUNC (rng_get()) #define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1) #define MICROPY_PY_TIME_TIME_TIME_NS (1) -#define MICROPY_PY_TIME_INCLUDEFILE "ports/stm32/modutime.c" +#define MICROPY_PY_TIME_INCLUDEFILE "ports/stm32/modtime.c" #ifndef MICROPY_PY_TIMEQ #define MICROPY_PY_TIMEQ (1) #endif diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 9ff19aab988..a8981e8f5c6 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -201,7 +201,7 @@ SRC_C += \ mpthreadport.c \ input.c \ modmachine.c \ - moduselect.c \ + modselect.c \ alloc.c \ fatfs_port.c \ mpbthciport.c \ @@ -210,7 +210,7 @@ SRC_C += \ mpbtstackport_usb.c \ mpnimbleport.c \ modtermios.c \ - modusocket.c \ + modsocket.c \ modffi.c \ modjni.c \ $(wildcard $(VARIANT_DIR)/*.c) diff --git a/ports/unix/moduos.c b/ports/unix/modos.c similarity index 100% rename from ports/unix/moduos.c rename to ports/unix/modos.c diff --git a/ports/unix/moduselect.c b/ports/unix/modselect.c similarity index 100% rename from ports/unix/moduselect.c rename to ports/unix/modselect.c diff --git a/ports/unix/modusocket.c b/ports/unix/modsocket.c similarity index 100% rename from ports/unix/modusocket.c rename to ports/unix/modsocket.c diff --git a/ports/unix/modutime.c b/ports/unix/modtime.c similarity index 100% rename from ports/unix/modutime.c rename to ports/unix/modtime.c diff --git a/ports/unix/variants/mpconfigvariant_common.h b/ports/unix/variants/mpconfigvariant_common.h index cc50d426ceb..afdd313134d 100644 --- a/ports/unix/variants/mpconfigvariant_common.h +++ b/ports/unix/variants/mpconfigvariant_common.h @@ -87,7 +87,7 @@ #define MICROPY_PY_SYS_EXC_INFO (1) // Configure the "os" module with extra unix features. -#define MICROPY_PY_OS_INCLUDEFILE "ports/unix/moduos.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/unix/modos.c" #define MICROPY_PY_OS_ERRNO (1) #define MICROPY_PY_OS_GETENV_PUTENV_UNSETENV (1) #define MICROPY_PY_OS_SEP (1) @@ -98,7 +98,7 @@ #define MICROPY_PY_TIME (1) #define MICROPY_PY_TIME_TIME_TIME_NS (1) #define MICROPY_PY_TIME_CUSTOM_SLEEP (1) -#define MICROPY_PY_TIME_INCLUDEFILE "ports/unix/modutime.c" +#define MICROPY_PY_TIME_INCLUDEFILE "ports/unix/modtime.c" // Enable the utimeq module used by the previous (v2) version of uasyncio. #define MICROPY_PY_TIMEQ (1) diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h index 87e12562b16..239dcfec916 100644 --- a/ports/windows/mpconfigport.h +++ b/ports/windows/mpconfigport.h @@ -131,7 +131,7 @@ #endif #define MICROPY_PY_OS (1) -#define MICROPY_PY_OS_INCLUDEFILE "ports/unix/moduos.c" +#define MICROPY_PY_OS_INCLUDEFILE "ports/unix/modos.c" #define MICROPY_PY_OS_ERRNO (1) #define MICROPY_PY_OS_GETENV_PUTENV_UNSETENV (1) #define MICROPY_PY_OS_SEP (1) @@ -141,7 +141,7 @@ #define MICROPY_PY_TIME (1) #define MICROPY_PY_TIME_TIME_TIME_NS (1) #define MICROPY_PY_TIME_CUSTOM_SLEEP (1) -#define MICROPY_PY_TIME_INCLUDEFILE "ports/unix/modutime.c" +#define MICROPY_PY_TIME_INCLUDEFILE "ports/unix/modtime.c" #define MICROPY_PY_ERRNO (1) #define MICROPY_PY_UCTYPES (1) #define MICROPY_PY_ZLIB (1) diff --git a/ports/windows/msvc/sources.props b/ports/windows/msvc/sources.props index de950c3ac93..24cdcd82daf 100644 --- a/ports/windows/msvc/sources.props +++ b/ports/windows/msvc/sources.props @@ -8,18 +8,18 @@ - + - - - - - - - - - - + + + + + + + + + + diff --git a/ports/zephyr/CMakeLists.txt b/ports/zephyr/CMakeLists.txt index 39942bdc84f..ddc613a2c07 100644 --- a/ports/zephyr/CMakeLists.txt +++ b/ports/zephyr/CMakeLists.txt @@ -43,7 +43,7 @@ set(MICROPY_SOURCE_PORT machine_uart.c modbluetooth_zephyr.c modmachine.c - modusocket.c + modsocket.c modzephyr.c modzsensor.c mphalport.c diff --git a/ports/zephyr/modusocket.c b/ports/zephyr/modsocket.c similarity index 100% rename from ports/zephyr/modusocket.c rename to ports/zephyr/modsocket.c diff --git a/ports/zephyr/modutime.c b/ports/zephyr/modtime.c similarity index 100% rename from ports/zephyr/modutime.c rename to ports/zephyr/modtime.c diff --git a/ports/zephyr/mpconfigport.h b/ports/zephyr/mpconfigport.h index ec759bda775..df24e52002b 100644 --- a/ports/zephyr/mpconfigport.h +++ b/ports/zephyr/mpconfigport.h @@ -87,7 +87,7 @@ #define MICROPY_PY_OS (1) #define MICROPY_PY_TIME (1) #define MICROPY_PY_TIME_TIME_TIME_NS (1) -#define MICROPY_PY_TIME_INCLUDEFILE "ports/zephyr/modutime.c" +#define MICROPY_PY_TIME_INCLUDEFILE "ports/zephyr/modtime.c" #define MICROPY_PY_ZEPHYR (1) #define MICROPY_PY_ZSENSOR (1) #define MICROPY_PY_SYS_MODULES (0) diff --git a/py/moduerrno.c b/py/moderrno.c similarity index 100% rename from py/moduerrno.c rename to py/moderrno.c diff --git a/py/py.cmake b/py/py.cmake index 07d1fe05ffa..95a841b5f4a 100644 --- a/py/py.cmake +++ b/py/py.cmake @@ -47,7 +47,7 @@ set(MICROPY_SOURCE_PY ${MICROPY_PY_DIR}/modstruct.c ${MICROPY_PY_DIR}/modsys.c ${MICROPY_PY_DIR}/modthread.c - ${MICROPY_PY_DIR}/moduerrno.c + ${MICROPY_PY_DIR}/moderrno.c ${MICROPY_PY_DIR}/mpprint.c ${MICROPY_PY_DIR}/mpstate.c ${MICROPY_PY_DIR}/mpz.c diff --git a/py/py.mk b/py/py.mk index 1dc0c8641f3..ffb853c652d 100644 --- a/py/py.mk +++ b/py/py.mk @@ -185,7 +185,7 @@ PY_CORE_O_BASENAME = $(addprefix py/,\ modmicropython.o \ modstruct.o \ modsys.o \ - moduerrno.o \ + moderrno.o \ modthread.o \ vm.o \ bc.o \ diff --git a/tools/codeformat.py b/tools/codeformat.py index 4a2cfb3367d..517aced37a1 100755 --- a/tools/codeformat.py +++ b/tools/codeformat.py @@ -69,8 +69,8 @@ "ports/nrf/modules/machine/*.[ch]", "ports/nrf/modules/music/*.[ch]", "ports/nrf/modules/ubluepy/*.[ch]", - "ports/nrf/modules/uos/*.[ch]", - "ports/nrf/modules/utime/*.[ch]", + "ports/nrf/modules/os/*.[ch]", + "ports/nrf/modules/time/*.[ch]", # STM32 USB dev/host code is mostly 3rd party. "ports/stm32/usbdev/**/*.[ch]", "ports/stm32/usbhost/**/*.[ch]", From 24c02c4eb5f11200f876bb57cd63a9d0bae91fd3 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 2 Jun 2023 12:28:07 +1000 Subject: [PATCH 0015/4300] py/makemoduledefs.py: Add a way to register extensible built-in modules. Signed-off-by: Jim Mussared --- py/builtinhelp.c | 1 + py/builtinimport.c | 22 ++++++++------------- py/makemoduledefs.py | 46 ++++++++++++++++++++++++++++++++++--------- py/makeqstrdefs.py | 4 ++-- py/obj.h | 3 +++ py/objmodule.c | 47 +++++++++++++++++++++++++++++++++++++++----- py/objmodule.h | 3 ++- py/repl.c | 4 ++-- 8 files changed, 97 insertions(+), 33 deletions(-) diff --git a/py/builtinhelp.c b/py/builtinhelp.c index 93d94a389d2..c60ed44e9c6 100644 --- a/py/builtinhelp.c +++ b/py/builtinhelp.c @@ -79,6 +79,7 @@ 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); + mp_help_add_from_map(list, &mp_builtin_extensible_module_map); #if MICROPY_MODULE_FROZEN extern const char mp_frozen_names[]; diff --git a/py/builtinimport.c b/py/builtinimport.c index 299877de639..15521c77c42 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -384,28 +384,22 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, // An import of a non-extensible built-in will always bypass the // filesystem. e.g. `import micropython` or `import pyb`. - module_obj = mp_module_get_builtin(level_mod_name); + module_obj = mp_module_get_builtin(level_mod_name, false); if (module_obj != MP_OBJ_NULL) { return module_obj; } - #if MICROPY_PY_SYS - // Never allow sys to be overridden from the filesystem. If weak links - // are disabled, then this also provides a default weak link so that - // `import sys` is treated like `import usys` (and therefore bypasses - // the filesystem). - if (level_mod_name == MP_QSTR_sys) { - return MP_OBJ_FROM_PTR(&mp_module_sys); - } - #endif - // First module in the dotted-name; search for a directory or file // relative to all the locations in sys.path. stat = stat_top_level(level_mod_name, &path); // TODO: If stat failed, now try extensible built-in modules. - - // TODO: If importing `ufoo`, try `foo`. + if (stat == MP_IMPORT_STAT_NO_EXIST) { + module_obj = mp_module_get_builtin(level_mod_name, true); + if (module_obj != MP_OBJ_NULL) { + return module_obj; + } + } } else { DEBUG_printf("Searching for sub-module\n"); @@ -637,7 +631,7 @@ mp_obj_t mp_builtin___import___default(size_t n_args, const mp_obj_t *args) { // Try the name directly as a built-in. qstr module_name_qstr = mp_obj_str_get_qstr(args[0]); - mp_obj_t module_obj = mp_module_get_builtin(module_name_qstr); + mp_obj_t module_obj = mp_module_get_builtin(module_name_qstr, false); if (module_obj != MP_OBJ_NULL) { return module_obj; } diff --git a/py/makemoduledefs.py b/py/makemoduledefs.py index 9061cd890be..2f787905a9d 100644 --- a/py/makemoduledefs.py +++ b/py/makemoduledefs.py @@ -1,8 +1,17 @@ """ This pre-processor parses a single file containing a list of -MP_REGISTER_MODULE(module_name, obj_module) -These are used to generate a header with the required entries for -"mp_rom_map_elem_t mp_builtin_module_table[]" in py/objmodule.c +`MP_REGISTER_MODULE(MP_QSTR_module_name, obj_module)` or +`MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_module_name, obj_module)` +(i.e. the output of `py/makeqstrdefs.py cat module`). + +The output is a header (typically moduledefs.h) which is included by +py/objmodule.c that contains entries to be included in the definition of + - mp_rom_map_elem_t mp_builtin_module_table[] + - mp_rom_map_elem_t mp_builtin_extensible_module_table[] + +Extensible modules are modules that can be overridden from the filesystem, see +py/builtinimnport.c:process_import_at_level. Regular modules will always use +the built-in version. """ from __future__ import print_function @@ -13,7 +22,10 @@ import argparse -pattern = re.compile(r"\s*MP_REGISTER_MODULE\((.*?),\s*(.*?)\);", flags=re.DOTALL) +pattern = re.compile( + r"\s*(MP_REGISTER_MODULE|MP_REGISTER_EXTENSIBLE_MODULE)\(MP_QSTR_(.*?),\s*(.*?)\);", + flags=re.DOTALL, +) def find_module_registrations(filename): @@ -37,14 +49,23 @@ def generate_module_table_header(modules): # Print header file for all external modules. mod_defs = set() + extensible_mod_defs = set() print("// Automatically generated by makemoduledefs.py.\n") - for module_name, obj_module in modules: + for macro_name, module_name, obj_module in modules: mod_def = "MODULE_DEF_{}".format(module_name.upper()) - mod_defs.add(mod_def) + if macro_name == "MP_REGISTER_MODULE": + mod_defs.add(mod_def) + elif macro_name == "MP_REGISTER_EXTENSIBLE_MODULE": + extensible_mod_defs.add(mod_def) if "," in obj_module: print( - "ERROR: Call to MP_REGISTER_MODULE({}, {}) should be MP_REGISTER_MODULE({}, {})\n".format( - module_name, obj_module, module_name, obj_module.split(",")[0] + "ERROR: Call to {}({}, {}) should be {}({}, {})\n".format( + macro_name, + module_name, + obj_module, + macro_name, + module_name, + obj_module.split(",")[0], ), file=sys.stderr, ) @@ -53,7 +74,7 @@ def generate_module_table_header(modules): ( "extern const struct _mp_obj_module_t {obj_module};\n" "#undef {mod_def}\n" - "#define {mod_def} {{ MP_ROM_QSTR({module_name}), MP_ROM_PTR(&{obj_module}) }},\n" + "#define {mod_def} {{ MP_ROM_QSTR(MP_QSTR_{module_name}), MP_ROM_PTR(&{obj_module}) }},\n" ).format( module_name=module_name, obj_module=obj_module, @@ -68,6 +89,13 @@ def generate_module_table_header(modules): print("// MICROPY_REGISTERED_MODULES") + 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") + def main(): parser = argparse.ArgumentParser() diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index 13a8b54d67c..dd96513351e 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -21,7 +21,7 @@ # Extract MP_COMPRESSED_ROM_TEXT("") macros. (Which come from MP_ERROR_TEXT) _MODE_COMPRESS = "compress" -# Extract MP_REGISTER_MODULE(...) macros. +# Extract MP_REGISTER_(EXTENSIBLE_)MODULE(...) macros. _MODE_MODULE = "module" # Extract MP_REGISTER_ROOT_POINTER(...) macros. @@ -93,7 +93,7 @@ def process_file(f): elif args.mode == _MODE_COMPRESS: re_match = re.compile(r'MP_COMPRESSED_ROM_TEXT\("([^"]*)"\)') elif args.mode == _MODE_MODULE: - re_match = re.compile(r"MP_REGISTER_MODULE\(.*?,\s*.*?\);") + re_match = re.compile(r"MP_REGISTER_(?:EXTENSIBLE_)?MODULE\(.*?,\s*.*?\);") elif args.mode == _MODE_ROOT_POINTER: re_match = re.compile(r"MP_REGISTER_ROOT_POINTER\(.*?\);") output = [] diff --git a/py/obj.h b/py/obj.h index 3735b72c22c..005383e9f38 100644 --- a/py/obj.h +++ b/py/obj.h @@ -434,6 +434,9 @@ typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t; // param obj_module: mp_obj_module_t instance #define MP_REGISTER_MODULE(module_name, obj_module) +// As above, but allow this module to be extended from the filesystem. +#define MP_REGISTER_EXTENSIBLE_MODULE(module_name, obj_module) + // Declare a root pointer (to avoid garbage collection of a global static variable). // param variable_declaration: a valid C variable declaration #define MP_REGISTER_ROOT_POINTER(variable_declaration) diff --git a/py/objmodule.c b/py/objmodule.c index e63fb18a1ea..bf383662667 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -166,17 +166,54 @@ mp_obj_t mp_obj_new_module(qstr module_name) { // Global module table and related functions STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { - // builtin modules declared with MP_REGISTER_MODULE() + // built-in modules declared with MP_REGISTER_MODULE() MICROPY_REGISTERED_MODULES }; MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table); -// Attempts to find (and initialise) a builtin, otherwise returns +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); + +// Attempts to find (and initialise) a built-in, otherwise returns // MP_OBJ_NULL. -mp_obj_t mp_module_get_builtin(qstr module_name) { - mp_map_elem_t *elem = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); +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 (!elem) { - return MP_OBJ_NULL; + #if MICROPY_PY_SYS + // Special case for sys, which isn't extensible but can always be + // imported with the alias `usys`. + if (module_name == MP_QSTR_usys) { + return MP_OBJ_FROM_PTR(&mp_module_sys); + } + #endif + + if (extensible) { + // At this point we've already tried non-extensible built-ins, the + // filesystem, and now extensible built-ins. No match, so fail + // the import. + return MP_OBJ_NULL; + } + + // We're trying to match a non-extensible built-in (i.e. before trying + // the filesystem), but if the user is importing `ufoo`, _and_ `foo` + // is an extensible module, then allow it as a way of forcing the + // built-in. Essentially, this makes it as if all the extensible + // built-ins also had non-extensible aliases named `ufoo`. Newer code + // should be using sys.path to force the built-in, but this retains + // the old behaviour of the u-prefix being used to force a built-in + // import. + size_t module_name_len; + const char *module_name_str = (const char *)qstr_data(module_name, &module_name_len); + 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); + if (!elem) { + return MP_OBJ_NULL; + } } #if MICROPY_MODULE_BUILTIN_INIT diff --git a/py/objmodule.h b/py/objmodule.h index 11bd7bb42fd..63ae3c3bdfa 100644 --- a/py/objmodule.h +++ b/py/objmodule.h @@ -32,8 +32,9 @@ #define MP_MODULE_ATTR_DELEGATION_ENTRY(ptr) { MP_ROM_QSTR(MP_QSTRnull), MP_ROM_PTR(ptr) } extern const mp_map_t mp_builtin_module_map; +extern const mp_map_t mp_builtin_extensible_module_map; -mp_obj_t mp_module_get_builtin(qstr module_name); +mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible); void mp_module_generic_attr(qstr attr, mp_obj_t *dest, const uint16_t *keys, mp_obj_t *values); diff --git a/py/repl.c b/py/repl.c index 0369b021951..cf69d3d8993 100644 --- a/py/repl.c +++ b/py/repl.c @@ -162,8 +162,8 @@ 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); + 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); } } From 2eba98f1e0d292de0f7e48ce228221ef50c01967 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 2 Jun 2023 12:33:25 +1000 Subject: [PATCH 0016/4300] all: Use MP_REGISTER_EXTENSIBLE_MODULE for overrideable built-ins. Signed-off-by: Jim Mussared --- extmod/modbinascii.c | 2 +- extmod/modbluetooth.c | 6 +++++- extmod/modcryptolib.c | 6 +++++- extmod/modhashlib.c | 2 +- extmod/modheapq.c | 2 +- extmod/modjson.c | 2 +- extmod/modlwip.c | 2 +- extmod/modos.c | 2 +- extmod/modplatform.c | 2 +- extmod/modrandom.c | 2 +- extmod/modre.c | 2 +- extmod/modselect.c | 2 +- extmod/modsocket.c | 2 +- extmod/modssl_axtls.c | 2 +- extmod/modssl_mbedtls.c | 2 +- extmod/modtime.c | 2 +- extmod/modtimeq.c | 2 +- extmod/moductypes.c | 2 ++ extmod/modwebsocket.c | 6 +++++- extmod/modzlib.c | 2 +- ports/cc3200/mods/modmachine.c | 2 +- ports/cc3200/mods/modos.c | 2 +- ports/cc3200/mods/modsocket.c | 2 +- ports/cc3200/mods/modssl.c | 2 +- ports/esp32/modmachine.c | 2 +- ports/esp32/modsocket.c | 2 +- ports/esp8266/modmachine.c | 2 +- ports/mimxrt/modmachine.c | 2 +- ports/nrf/modules/machine/modmachine.c | 2 +- ports/nrf/modules/os/modos.c | 2 +- ports/qemu-arm/modmachine.c | 2 +- ports/renesas-ra/modmachine.c | 2 +- ports/rp2/modmachine.c | 2 +- ports/samd/modmachine.c | 2 +- ports/stm32/modmachine.c | 2 +- ports/unix/modmachine.c | 2 +- ports/unix/modselect.c | 2 +- ports/unix/modsocket.c | 2 +- ports/zephyr/modmachine.c | 2 +- ports/zephyr/modsocket.c | 2 +- py/builtinimport.c | 11 +++++++---- py/modarray.c | 2 +- py/modcollections.c | 2 +- py/moderrno.c | 2 +- py/modio.c | 2 +- py/modstruct.c | 2 +- py/modsys.c | 3 +++ 47 files changed, 68 insertions(+), 48 deletions(-) diff --git a/extmod/modbinascii.c b/extmod/modbinascii.c index af8eab79f0a..46027d5fd5c 100644 --- a/extmod/modbinascii.c +++ b/extmod/modbinascii.c @@ -203,6 +203,6 @@ const mp_obj_module_t mp_module_binascii = { .globals = (mp_obj_dict_t *)&mp_module_binascii_globals, }; -MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_binascii); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_binascii, mp_module_binascii); #endif // MICROPY_PY_BINASCII diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c index 628c643a586..7b13f9556c4 100644 --- a/extmod/modbluetooth.c +++ b/extmod/modbluetooth.c @@ -1004,7 +1004,11 @@ const mp_obj_module_t mp_module_bluetooth = { .globals = (mp_obj_dict_t *)&mp_module_bluetooth_globals, }; -MP_REGISTER_MODULE(MP_QSTR_bluetooth, mp_module_bluetooth); +// This module should not be extensible (as it is not a CPython standard +// library nor is it necessary to override from the filesystem), however it +// has previously been known as `ubluetooth`, so by making it extensible the +// `ubluetooth` alias will continue to work. +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_bluetooth, mp_module_bluetooth); // Helpers diff --git a/extmod/modcryptolib.c b/extmod/modcryptolib.c index 22994772599..b33d8533fc5 100644 --- a/extmod/modcryptolib.c +++ b/extmod/modcryptolib.c @@ -375,6 +375,10 @@ const mp_obj_module_t mp_module_cryptolib = { .globals = (mp_obj_dict_t *)&mp_module_cryptolib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_cryptolib, mp_module_cryptolib); +// This module should not be extensible (as it is not a CPython standard +// library nor is it necessary to override from the filesystem), however it +// has previously been known as `ucryptolib`, so by making it extensible the +// `ucryptolib` alias will continue to work. +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_cryptolib, mp_module_cryptolib); #endif // MICROPY_PY_CRYPTOLIB diff --git a/extmod/modhashlib.c b/extmod/modhashlib.c index 1b94cc01a04..3fafe6316de 100644 --- a/extmod/modhashlib.c +++ b/extmod/modhashlib.c @@ -374,6 +374,6 @@ const mp_obj_module_t mp_module_hashlib = { .globals = (mp_obj_dict_t *)&mp_module_hashlib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_hashlib, mp_module_hashlib); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_hashlib, mp_module_hashlib); #endif // MICROPY_PY_HASHLIB diff --git a/extmod/modheapq.c b/extmod/modheapq.c index 79a12c2b9c5..db1e35bac28 100644 --- a/extmod/modheapq.c +++ b/extmod/modheapq.c @@ -118,7 +118,7 @@ const mp_obj_module_t mp_module_heapq = { .globals = (mp_obj_dict_t *)&mp_module_heapq_globals, }; -MP_REGISTER_MODULE(MP_QSTR_heapq, mp_module_heapq); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_heapq, mp_module_heapq); #endif #endif // MICROPY_PY_HEAPQ diff --git a/extmod/modjson.c b/extmod/modjson.c index 1b475543e16..1772b729988 100644 --- a/extmod/modjson.c +++ b/extmod/modjson.c @@ -381,6 +381,6 @@ const mp_obj_module_t mp_module_json = { .globals = (mp_obj_dict_t *)&mp_module_json_globals, }; -MP_REGISTER_MODULE(MP_QSTR_json, mp_module_json); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_json, mp_module_json); #endif // MICROPY_PY_JSON diff --git a/extmod/modlwip.c b/extmod/modlwip.c index 24047b0a98c..0d4c03c68a8 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -1802,7 +1802,7 @@ const mp_obj_module_t mp_module_lwip = { MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip); // On LWIP-ports, this is the socket module (replaces extmod/modsocket.c). -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_lwip); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_lwip); MP_REGISTER_ROOT_POINTER(mp_obj_t lwip_slip_stream); diff --git a/extmod/modos.c b/extmod/modos.c index e962a6c1718..6df49d7f849 100644 --- a/extmod/modos.c +++ b/extmod/modos.c @@ -195,6 +195,6 @@ const mp_obj_module_t mp_module_os = { .globals = (mp_obj_dict_t *)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_os, mp_module_os); #endif // MICROPY_PY_OS diff --git a/extmod/modplatform.c b/extmod/modplatform.c index 4d10bdb4df0..73846f946d0 100644 --- a/extmod/modplatform.c +++ b/extmod/modplatform.c @@ -75,6 +75,6 @@ const mp_obj_module_t mp_module_platform = { .globals = (mp_obj_dict_t *)&modplatform_globals, }; -MP_REGISTER_MODULE(MP_QSTR_platform, mp_module_platform); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_platform, mp_module_platform); #endif // MICROPY_PY_PLATFORM diff --git a/extmod/modrandom.c b/extmod/modrandom.c index 1c697aec70d..e65f31488bf 100644 --- a/extmod/modrandom.c +++ b/extmod/modrandom.c @@ -255,7 +255,7 @@ const mp_obj_module_t mp_module_random = { .globals = (mp_obj_dict_t *)&mp_module_random_globals, }; -MP_REGISTER_MODULE(MP_QSTR_random, mp_module_random); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_random, mp_module_random); #endif #endif // MICROPY_PY_RANDOM diff --git a/extmod/modre.c b/extmod/modre.c index c8a019be891..7f00b1c23c4 100644 --- a/extmod/modre.c +++ b/extmod/modre.c @@ -470,7 +470,7 @@ const mp_obj_module_t mp_module_re = { .globals = (mp_obj_dict_t *)&mp_module_re_globals, }; -MP_REGISTER_MODULE(MP_QSTR_re, mp_module_re); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_re, mp_module_re); #endif // Source files #include'd here to make sure they're compiled in diff --git a/extmod/modselect.c b/extmod/modselect.c index 011d5cb832c..3d7ccbd9955 100644 --- a/extmod/modselect.c +++ b/extmod/modselect.c @@ -373,6 +373,6 @@ const mp_obj_module_t mp_module_select = { .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; -MP_REGISTER_MODULE(MP_QSTR_select, mp_module_select); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_select, mp_module_select); #endif // MICROPY_PY_SELECT diff --git a/extmod/modsocket.c b/extmod/modsocket.c index 316a578ac20..488b6d17125 100644 --- a/extmod/modsocket.c +++ b/extmod/modsocket.c @@ -653,6 +653,6 @@ const mp_obj_module_t mp_module_socket = { .globals = (mp_obj_dict_t *)&mp_module_socket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket); #endif // MICROPY_PY_NETWORK && MICROPY_PY_SOCKET && !MICROPY_PY_LWIP diff --git a/extmod/modssl_axtls.c b/extmod/modssl_axtls.c index 1c9caf76ebf..de6e0ce5dd1 100644 --- a/extmod/modssl_axtls.c +++ b/extmod/modssl_axtls.c @@ -357,6 +357,6 @@ const mp_obj_module_t mp_module_ssl = { .globals = (mp_obj_dict_t *)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_ssl, mp_module_ssl); #endif // MICROPY_PY_SSL && MICROPY_SSL_AXTLS diff --git a/extmod/modssl_mbedtls.c b/extmod/modssl_mbedtls.c index d724e0a08a5..c230b1eaa24 100644 --- a/extmod/modssl_mbedtls.c +++ b/extmod/modssl_mbedtls.c @@ -507,6 +507,6 @@ const mp_obj_module_t mp_module_ssl = { .globals = (mp_obj_dict_t *)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_ssl, mp_module_ssl); #endif // MICROPY_PY_SSL && MICROPY_SSL_MBEDTLS diff --git a/extmod/modtime.c b/extmod/modtime.c index 163b874d5e0..805c2621c0b 100644 --- a/extmod/modtime.c +++ b/extmod/modtime.c @@ -231,6 +231,6 @@ const mp_obj_module_t mp_module_time = { .globals = (mp_obj_dict_t *)&mp_module_time_globals, }; -MP_REGISTER_MODULE(MP_QSTR_time, mp_module_time); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_time, mp_module_time); #endif // MICROPY_PY_TIME diff --git a/extmod/modtimeq.c b/extmod/modtimeq.c index 7c037ea0a90..4edb7dd3c80 100644 --- a/extmod/modtimeq.c +++ b/extmod/modtimeq.c @@ -230,6 +230,6 @@ const mp_obj_module_t mp_module_timeq = { .globals = (mp_obj_dict_t *)&mp_module_timeq_globals, }; -MP_REGISTER_MODULE(MP_QSTR_timeq, mp_module_timeq); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_timeq, mp_module_timeq); #endif // MICROPY_PY_TIMEQ diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 86d82f03ba0..63be621fbcb 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -718,6 +718,8 @@ const mp_obj_module_t mp_module_uctypes = { .globals = (mp_obj_dict_t *)&mp_module_uctypes_globals, }; +// uctypes is not a Python standard library module (hence "uctypes" +// not "ctypes") and therefore shouldn't be extensible. MP_REGISTER_MODULE(MP_QSTR_uctypes, mp_module_uctypes); #endif diff --git a/extmod/modwebsocket.c b/extmod/modwebsocket.c index 3bf50cc58c8..d2cb7203962 100644 --- a/extmod/modwebsocket.c +++ b/extmod/modwebsocket.c @@ -311,6 +311,10 @@ const mp_obj_module_t mp_module_websocket = { .globals = (mp_obj_dict_t *)&websocket_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_websocket, mp_module_websocket); +// This module should not be extensible (as it is not a CPython standard +// library nor is it necessary to override from the filesystem), however it +// has previously been known as `uwebsocket`, so by making it extensible the +// `uwebsocket` alias will continue to work. +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_websocket, mp_module_websocket); #endif // MICROPY_PY_WEBSOCKET diff --git a/extmod/modzlib.c b/extmod/modzlib.c index a912f113ce4..31096cfeb9e 100644 --- a/extmod/modzlib.c +++ b/extmod/modzlib.c @@ -224,7 +224,7 @@ const mp_obj_module_t mp_module_zlib = { }; -MP_REGISTER_MODULE(MP_QSTR_zlib, mp_module_zlib); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_zlib, mp_module_zlib); #endif // Source files #include'd here to make sure they're compiled in diff --git a/ports/cc3200/mods/modmachine.c b/ports/cc3200/mods/modmachine.c index a695fdccae2..bdf963c31a6 100644 --- a/ports/cc3200/mods/modmachine.c +++ b/ports/cc3200/mods/modmachine.c @@ -214,5 +214,5 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t*)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); MP_REGISTER_ROOT_POINTER(mp_obj_t machine_config_main); diff --git a/ports/cc3200/mods/modos.c b/ports/cc3200/mods/modos.c index 7b1e8d79fd1..1a854750f23 100644 --- a/ports/cc3200/mods/modos.c +++ b/ports/cc3200/mods/modos.c @@ -180,4 +180,4 @@ const mp_obj_module_t mp_module_os = { .globals = (mp_obj_dict_t*)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_os, mp_module_os); diff --git a/ports/cc3200/mods/modsocket.c b/ports/cc3200/mods/modsocket.c index fd09cd6a413..a107fa71207 100644 --- a/ports/cc3200/mods/modsocket.c +++ b/ports/cc3200/mods/modsocket.c @@ -818,4 +818,4 @@ const mp_obj_module_t mp_module_socket = { .globals = (mp_obj_dict_t*)&mp_module_socket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket); diff --git a/ports/cc3200/mods/modssl.c b/ports/cc3200/mods/modssl.c index eb3aea1f85b..15c825fcf4d 100644 --- a/ports/cc3200/mods/modssl.c +++ b/ports/cc3200/mods/modssl.c @@ -160,4 +160,4 @@ const mp_obj_module_t mp_module_ssl = { .globals = (mp_obj_dict_t*)&mp_module_ssl_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_ssl, mp_module_ssl); diff --git a/ports/esp32/modmachine.c b/ports/esp32/modmachine.c index a863f716c71..fc19618b730 100644 --- a/ports/esp32/modmachine.c +++ b/ports/esp32/modmachine.c @@ -353,6 +353,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index 0b2d40e333c..731f69fbc22 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -872,4 +872,4 @@ const mp_obj_module_t mp_module_socket = { // Note: This port doesn't define MICROPY_PY_SOCKET or MICROPY_PY_LWIP so // this will not conflict with the common implementation provided by // extmod/mod{lwip,socket}.c. -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket); diff --git a/ports/esp8266/modmachine.c b/ports/esp8266/modmachine.c index 383f46dda70..64346b4debd 100644 --- a/ports/esp8266/modmachine.c +++ b/ports/esp8266/modmachine.c @@ -456,6 +456,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/mimxrt/modmachine.c b/ports/mimxrt/modmachine.c index 098c3b949a2..423a67d6095 100644 --- a/ports/mimxrt/modmachine.c +++ b/ports/mimxrt/modmachine.c @@ -185,6 +185,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/nrf/modules/machine/modmachine.c b/ports/nrf/modules/machine/modmachine.c index b7cbdc7b2da..616757a96ae 100644 --- a/ports/nrf/modules/machine/modmachine.c +++ b/ports/nrf/modules/machine/modmachine.c @@ -266,6 +266,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t*)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/nrf/modules/os/modos.c b/ports/nrf/modules/os/modos.c index 7c54f28ab45..7654ac119bf 100644 --- a/ports/nrf/modules/os/modos.c +++ b/ports/nrf/modules/os/modos.c @@ -197,4 +197,4 @@ const mp_obj_module_t mp_module_os = { .globals = (mp_obj_dict_t*)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_os, mp_module_os); diff --git a/ports/qemu-arm/modmachine.c b/ports/qemu-arm/modmachine.c index 1f9151ff741..0d712f792ea 100644 --- a/ports/qemu-arm/modmachine.c +++ b/ports/qemu-arm/modmachine.c @@ -48,6 +48,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/renesas-ra/modmachine.c b/ports/renesas-ra/modmachine.c index 07e6103aaac..47f7e8c8057 100644 --- a/ports/renesas-ra/modmachine.c +++ b/ports/renesas-ra/modmachine.c @@ -307,6 +307,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/rp2/modmachine.c b/ports/rp2/modmachine.c index 61b91bda0a7..1efbb09312b 100644 --- a/ports/rp2/modmachine.c +++ b/ports/rp2/modmachine.c @@ -278,6 +278,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/samd/modmachine.c b/ports/samd/modmachine.c index 9890e3b590f..9d5b7c2e272 100644 --- a/ports/samd/modmachine.c +++ b/ports/samd/modmachine.c @@ -297,6 +297,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/stm32/modmachine.c b/ports/stm32/modmachine.c index e6eb73f9cb1..25fc66eb9c6 100644 --- a/ports/stm32/modmachine.c +++ b/ports/stm32/modmachine.c @@ -471,6 +471,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/unix/modmachine.c b/ports/unix/modmachine.c index 29ac532d2b0..dd3cbf96c04 100644 --- a/ports/unix/modmachine.c +++ b/ports/unix/modmachine.c @@ -110,6 +110,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/unix/modselect.c b/ports/unix/modselect.c index 97c3602e4bc..894820c63d9 100644 --- a/ports/unix/modselect.c +++ b/ports/unix/modselect.c @@ -351,6 +351,6 @@ const mp_obj_module_t mp_module_select = { .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; -MP_REGISTER_MODULE(MP_QSTR_select, mp_module_select); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_select, mp_module_select); #endif // MICROPY_PY_SELECT_POSIX diff --git a/ports/unix/modsocket.c b/ports/unix/modsocket.c index 9854f3cbce1..871be8dcf73 100644 --- a/ports/unix/modsocket.c +++ b/ports/unix/modsocket.c @@ -707,6 +707,6 @@ const mp_obj_module_t mp_module_socket = { .globals = (mp_obj_dict_t *)&mp_module_socket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket); #endif // MICROPY_PY_SOCKET diff --git a/ports/zephyr/modmachine.c b/ports/zephyr/modmachine.c index 6f4bbbdab61..63341680543 100644 --- a/ports/zephyr/modmachine.c +++ b/ports/zephyr/modmachine.c @@ -89,6 +89,6 @@ const mp_obj_module_t mp_module_machine = { .globals = (mp_obj_dict_t *)&machine_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine); #endif // MICROPY_PY_MACHINE diff --git a/ports/zephyr/modsocket.c b/ports/zephyr/modsocket.c index 8d4197410c2..eacdb049da4 100644 --- a/ports/zephyr/modsocket.c +++ b/ports/zephyr/modsocket.c @@ -473,6 +473,6 @@ const mp_obj_module_t mp_module_socket = { .globals = (mp_obj_dict_t *)&mp_module_socket_globals, }; -MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket); #endif // MICROPY_PY_SOCKET diff --git a/py/builtinimport.c b/py/builtinimport.c index 15521c77c42..8a125fc538a 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -380,20 +380,23 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, mp_obj_t module_obj; if (outer_module_obj == MP_OBJ_NULL) { + // First module in the dotted-name path. DEBUG_printf("Searching for top-level module\n"); // An import of a non-extensible built-in will always bypass the - // filesystem. e.g. `import micropython` or `import pyb`. + // filesystem. e.g. `import micropython` or `import pyb`. So try and + // match a non-extensible built-ins first. module_obj = mp_module_get_builtin(level_mod_name, false); if (module_obj != MP_OBJ_NULL) { return module_obj; } - // First module in the dotted-name; search for a directory or file - // relative to all the locations in sys.path. + // Next try the filesystem. Search for a directory or file relative to + // all the locations in sys.path. stat = stat_top_level(level_mod_name, &path); - // TODO: If stat failed, now try extensible built-in modules. + // If filesystem failed, now try and see if it matches an extensible + // built-in module. if (stat == MP_IMPORT_STAT_NO_EXIST) { module_obj = mp_module_get_builtin(level_mod_name, true); if (module_obj != MP_OBJ_NULL) { diff --git a/py/modarray.c b/py/modarray.c index cfed0fbb59c..ac2e56ed38b 100644 --- a/py/modarray.c +++ b/py/modarray.c @@ -40,6 +40,6 @@ const mp_obj_module_t mp_module_array = { .globals = (mp_obj_dict_t *)&mp_module_array_globals, }; -MP_REGISTER_MODULE(MP_QSTR_array, mp_module_array); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_array, mp_module_array); #endif diff --git a/py/modcollections.c b/py/modcollections.c index a56fe069eaa..30a5881bc2c 100644 --- a/py/modcollections.c +++ b/py/modcollections.c @@ -46,6 +46,6 @@ const mp_obj_module_t mp_module_collections = { .globals = (mp_obj_dict_t *)&mp_module_collections_globals, }; -MP_REGISTER_MODULE(MP_QSTR_collections, mp_module_collections); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_collections, mp_module_collections); #endif // MICROPY_PY_COLLECTIONS diff --git a/py/moderrno.c b/py/moderrno.c index 99ca101bd6e..4f0673a23a2 100644 --- a/py/moderrno.c +++ b/py/moderrno.c @@ -99,7 +99,7 @@ const mp_obj_module_t mp_module_errno = { .globals = (mp_obj_dict_t *)&mp_module_errno_globals, }; -MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_errno); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_errno, mp_module_errno); qstr mp_errno_to_str(mp_obj_t errno_val) { #if MICROPY_PY_ERRNO_ERRORCODE diff --git a/py/modio.c b/py/modio.c index 3462611d719..39317c52d54 100644 --- a/py/modio.c +++ b/py/modio.c @@ -226,6 +226,6 @@ const mp_obj_module_t mp_module_io = { .globals = (mp_obj_dict_t *)&mp_module_io_globals, }; -MP_REGISTER_MODULE(MP_QSTR_io, mp_module_io); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_io, mp_module_io); #endif diff --git a/py/modstruct.c b/py/modstruct.c index e908c73e1d9..42f91b282cd 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -266,6 +266,6 @@ const mp_obj_module_t mp_module_struct = { .globals = (mp_obj_dict_t *)&mp_module_struct_globals, }; -MP_REGISTER_MODULE(MP_QSTR_struct, mp_module_struct); +MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_struct, mp_module_struct); #endif diff --git a/py/modsys.c b/py/modsys.c index 1cfc09ecfbf..ddc732e0057 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -294,6 +294,9 @@ const mp_obj_module_t mp_module_sys = { .globals = (mp_obj_dict_t *)&mp_module_sys_globals, }; +// Unlike the other CPython-compatible modules, sys is not extensible from the +// filesystem. We rely on it to work so that things like sys.path are always +// available. MP_REGISTER_MODULE(MP_QSTR_sys, mp_module_sys); // If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is not enabled then these two lists From eb85f4d4c9c332c8e7bef9b20bb06e25f6f6c5d2 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 18 Aug 2022 21:40:53 +1000 Subject: [PATCH 0017/4300] examples/natmod: Rename umodule to module. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- examples/natmod/{uzlib => heapq}/Makefile | 6 +++--- examples/natmod/{uheapq/uheapq.c => heapq/heapq.c} | 0 examples/natmod/{uheapq => random}/Makefile | 6 +++--- examples/natmod/{urandom/urandom.c => random/random.c} | 0 examples/natmod/{ure => re}/Makefile | 6 +++--- examples/natmod/{ure/ure.c => re/re.c} | 0 examples/natmod/{urandom => zlib}/Makefile | 6 +++--- examples/natmod/{uzlib/uzlib.c => zlib/zlib.c} | 0 tools/ci.sh | 10 +++++----- 9 files changed, 17 insertions(+), 17 deletions(-) rename examples/natmod/{uzlib => heapq}/Makefile (68%) rename examples/natmod/{uheapq/uheapq.c => heapq/heapq.c} (100%) rename examples/natmod/{uheapq => random}/Makefile (67%) rename examples/natmod/{urandom/urandom.c => random/random.c} (100%) rename examples/natmod/{ure => re}/Makefile (69%) rename examples/natmod/{ure/ure.c => re/re.c} (100%) rename examples/natmod/{urandom => zlib}/Makefile (66%) rename examples/natmod/{uzlib/uzlib.c => zlib/zlib.c} (100%) diff --git a/examples/natmod/uzlib/Makefile b/examples/natmod/heapq/Makefile similarity index 68% rename from examples/natmod/uzlib/Makefile rename to examples/natmod/heapq/Makefile index 8761caf2dd2..af45b472da1 100644 --- a/examples/natmod/uzlib/Makefile +++ b/examples/natmod/heapq/Makefile @@ -1,11 +1,11 @@ # Location of top-level MicroPython directory MPY_DIR = ../../.. -# Name of module (different to built-in uzlib so it can coexist) -MOD = uzlib_$(ARCH) +# Name of module (different to built-in heapq so it can coexist) +MOD = heapq_$(ARCH) # Source files (.c or .py) -SRC = uzlib.c +SRC = heapq.c # Architecture to build for (x86, x64, armv7m, xtensa, xtensawin) ARCH = x64 diff --git a/examples/natmod/uheapq/uheapq.c b/examples/natmod/heapq/heapq.c similarity index 100% rename from examples/natmod/uheapq/uheapq.c rename to examples/natmod/heapq/heapq.c diff --git a/examples/natmod/uheapq/Makefile b/examples/natmod/random/Makefile similarity index 67% rename from examples/natmod/uheapq/Makefile rename to examples/natmod/random/Makefile index 55de3cc0818..5c50227b15f 100644 --- a/examples/natmod/uheapq/Makefile +++ b/examples/natmod/random/Makefile @@ -1,11 +1,11 @@ # Location of top-level MicroPython directory MPY_DIR = ../../.. -# Name of module (different to built-in uheapq so it can coexist) -MOD = uheapq_$(ARCH) +# Name of module (different to built-in random so it can coexist) +MOD = random_$(ARCH) # Source files (.c or .py) -SRC = uheapq.c +SRC = random.c # Architecture to build for (x86, x64, armv7m, xtensa, xtensawin) ARCH = x64 diff --git a/examples/natmod/urandom/urandom.c b/examples/natmod/random/random.c similarity index 100% rename from examples/natmod/urandom/urandom.c rename to examples/natmod/random/random.c diff --git a/examples/natmod/ure/Makefile b/examples/natmod/re/Makefile similarity index 69% rename from examples/natmod/ure/Makefile rename to examples/natmod/re/Makefile index f5254298fdd..1ba54011065 100644 --- a/examples/natmod/ure/Makefile +++ b/examples/natmod/re/Makefile @@ -1,11 +1,11 @@ # Location of top-level MicroPython directory MPY_DIR = ../../.. -# Name of module (different to built-in ure so it can coexist) -MOD = ure_$(ARCH) +# Name of module (different to built-in re so it can coexist) +MOD = re_$(ARCH) # Source files (.c or .py) -SRC = ure.c +SRC = re.c # Architecture to build for (x86, x64, armv7m, xtensa, xtensawin) ARCH = x64 diff --git a/examples/natmod/ure/ure.c b/examples/natmod/re/re.c similarity index 100% rename from examples/natmod/ure/ure.c rename to examples/natmod/re/re.c diff --git a/examples/natmod/urandom/Makefile b/examples/natmod/zlib/Makefile similarity index 66% rename from examples/natmod/urandom/Makefile rename to examples/natmod/zlib/Makefile index 3f018baaf76..e4b4e0712ef 100644 --- a/examples/natmod/urandom/Makefile +++ b/examples/natmod/zlib/Makefile @@ -1,11 +1,11 @@ # Location of top-level MicroPython directory MPY_DIR = ../../.. -# Name of module (different to built-in urandom so it can coexist) -MOD = urandom_$(ARCH) +# Name of module (different to built-in zlib so it can coexist) +MOD = zlib_$(ARCH) # Source files (.c or .py) -SRC = urandom.c +SRC = zlib.c # Architecture to build for (x86, x64, armv7m, xtensa, xtensawin) ARCH = x64 diff --git a/examples/natmod/uzlib/uzlib.c b/examples/natmod/zlib/zlib.c similarity index 100% rename from examples/natmod/uzlib/uzlib.c rename to examples/natmod/zlib/zlib.c diff --git a/tools/ci.sh b/tools/ci.sh index 8d361e2b397..21acc17535b 100755 --- a/tools/ci.sh +++ b/tools/ci.sh @@ -454,10 +454,10 @@ function ci_native_mpy_modules_build { make -C examples/natmod/features3 ARCH=$arch make -C examples/natmod/btree ARCH=$arch make -C examples/natmod/framebuf ARCH=$arch - make -C examples/natmod/uheapq ARCH=$arch - make -C examples/natmod/urandom ARCH=$arch - make -C examples/natmod/ure ARCH=$arch - make -C examples/natmod/uzlib ARCH=$arch + make -C examples/natmod/heapq ARCH=$arch + make -C examples/natmod/random ARCH=$arch + make -C examples/natmod/re ARCH=$arch + make -C examples/natmod/zlib ARCH=$arch } function ci_native_mpy_modules_32bit_build { @@ -523,7 +523,7 @@ function ci_unix_coverage_run_mpy_merge_tests { function ci_unix_coverage_run_native_mpy_tests { MICROPYPATH=examples/natmod/features2 ./ports/unix/build-coverage/micropython -m features2 - (cd tests && ./run-natmodtests.py "$@" extmod/{btree*,framebuf*,uheapq*,urandom*,ure*,uzlib*}.py) + (cd tests && ./run-natmodtests.py "$@" extmod/{btree*,framebuf*,heapq*,random*,re*,zlib*}.py) } function ci_unix_32bit_setup { From 13c817e61cf2f00fc398e01840e5d8c20e575c8c Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Mon, 5 Jun 2023 15:52:57 +1000 Subject: [PATCH 0018/4300] py/objmodule: Add a table of built-in modules with delegation. This replaces the previous QSTR_null entry in the globals dict which could leak out to Python (e.g. via iteration of mod.__dict__) and could lead to crashes. It results in smaller code size at the expense of turning a lookup into a loop, but the list it is looping over likely only contains one or two elements. To allow a module to register its custom attr function it can use the new `MP_REGISTER_MODULE_DELEGATION` macro. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- py/builtin.h | 2 ++ py/builtinhelp.c | 7 +------ py/makemoduledefs.py | 27 +++++++++++++++++++++++---- py/makeqstrdefs.py | 4 +++- py/modsys.c | 8 ++------ py/mpconfig.h | 4 ++-- py/obj.h | 4 ++++ py/objmodule.c | 44 ++++++++++++++++++++++++++++++-------------- py/objmodule.h | 3 --- 9 files changed, 67 insertions(+), 36 deletions(-) diff --git a/py/builtin.h b/py/builtin.h index 81d0789802b..57f275fb312 100644 --- a/py/builtin.h +++ b/py/builtin.h @@ -132,6 +132,8 @@ extern const mp_obj_module_t mp_module___main__; extern const mp_obj_module_t mp_module_builtins; extern const mp_obj_module_t mp_module_sys; +void mp_module_sys_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); + // Modules needed by the parser when MICROPY_COMP_MODULE_CONST is enabled. extern const mp_obj_module_t mp_module_errno; extern const mp_obj_module_t mp_module_uctypes; diff --git a/py/builtinhelp.c b/py/builtinhelp.c index c60ed44e9c6..9bd56cca096 100644 --- a/py/builtinhelp.c +++ b/py/builtinhelp.c @@ -151,12 +151,7 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) { if (map != NULL) { for (uint i = 0; i < map->alloc; i++) { mp_obj_t key = map->table[i].key; - if (key != MP_OBJ_NULL - #if MICROPY_MODULE_ATTR_DELEGATION - // MP_MODULE_ATTR_DELEGATION_ENTRY entries have MP_QSTRnull as qstr key. - && key != MP_OBJ_NEW_QSTR(MP_QSTRnull) - #endif - ) { + if (key != MP_OBJ_NULL) { mp_help_print_info_about_object(key, map->table[i].value); } } diff --git a/py/makemoduledefs.py b/py/makemoduledefs.py index 2f787905a9d..5a1362a4c98 100644 --- a/py/makemoduledefs.py +++ b/py/makemoduledefs.py @@ -22,11 +22,16 @@ import argparse -pattern = re.compile( +register_pattern = re.compile( r"\s*(MP_REGISTER_MODULE|MP_REGISTER_EXTENSIBLE_MODULE)\(MP_QSTR_(.*?),\s*(.*?)\);", flags=re.DOTALL, ) +delegation_pattern = re.compile( + r"\s*(?:MP_REGISTER_MODULE_DELEGATION)\((.*?),\s*(.*?)\);", + flags=re.DOTALL, +) + def find_module_registrations(filename): """Find any MP_REGISTER_MODULE definitions in the provided file. @@ -37,7 +42,8 @@ def find_module_registrations(filename): global pattern with io.open(filename, encoding="utf-8") as c_file_obj: - return set(re.findall(pattern, c_file_obj.read())) + c = c_file_obj.read() + return set(re.findall(register_pattern, c)), set(re.findall(delegation_pattern, c)) def generate_module_table_header(modules): @@ -50,7 +56,6 @@ def generate_module_table_header(modules): # Print header file for all external modules. mod_defs = set() extensible_mod_defs = set() - print("// Automatically generated by makemoduledefs.py.\n") for macro_name, module_name, obj_module in modules: mod_def = "MODULE_DEF_{}".format(module_name.upper()) if macro_name == "MP_REGISTER_MODULE": @@ -97,13 +102,27 @@ def generate_module_table_header(modules): print("// MICROPY_REGISTERED_EXTENSIBLE_MODULES") +def generate_module_delegations(delegations): + print("\n#define MICROPY_MODULE_DELEGATIONS \\") + for obj_module, fun_name in delegations: + print( + " {{ MP_ROM_PTR(&{obj_module}), {fun_name} }},".format( + obj_module=obj_module, fun_name=fun_name + ) + ) + print("// MICROPY_MODULE_DELEGATIONS") + + def main(): parser = argparse.ArgumentParser() parser.add_argument("file", nargs=1, help="file with MP_REGISTER_MODULE definitions") args = parser.parse_args() - modules = find_module_registrations(args.file[0]) + print("// Automatically generated by makemoduledefs.py.\n") + + modules, delegations = find_module_registrations(args.file[0]) generate_module_table_header(sorted(modules)) + generate_module_delegations(sorted(delegations)) if __name__ == "__main__": diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index dd96513351e..64249f76ce3 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -93,7 +93,9 @@ def process_file(f): elif args.mode == _MODE_COMPRESS: re_match = re.compile(r'MP_COMPRESSED_ROM_TEXT\("([^"]*)"\)') elif args.mode == _MODE_MODULE: - re_match = re.compile(r"MP_REGISTER_(?:EXTENSIBLE_)?MODULE\(.*?,\s*.*?\);") + re_match = re.compile( + r"(?:MP_REGISTER_MODULE|MP_REGISTER_EXTENSIBLE_MODULE|MP_REGISTER_MODULE_DELEGATION)\(.*?,\s*.*?\);" + ) elif args.mode == _MODE_ROOT_POINTER: re_match = re.compile(r"MP_REGISTER_ROOT_POINTER\(.*?\);") output = [] diff --git a/py/modsys.c b/py/modsys.c index ddc732e0057..a0ecb87b5f3 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -207,7 +207,7 @@ STATIC const uint16_t sys_mutable_keys[] = { MP_QSTRnull, }; -STATIC void mp_module_sys_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { +void mp_module_sys_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { MP_STATIC_ASSERT(MP_ARRAY_SIZE(sys_mutable_keys) == MP_SYS_MUTABLE_NUM + 1); MP_STATIC_ASSERT(MP_ARRAY_SIZE(MP_STATE_VM(sys_mutable)) == MP_SYS_MUTABLE_NUM); mp_module_generic_attr(attr, dest, sys_mutable_keys, MP_STATE_VM(sys_mutable)); @@ -280,11 +280,6 @@ STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = { #if MICROPY_PY_SYS_ATEXIT { MP_ROM_QSTR(MP_QSTR_atexit), MP_ROM_PTR(&mp_sys_atexit_obj) }, #endif - - #if MICROPY_PY_SYS_ATTR_DELEGATION - // Delegation of attr lookup. - MP_MODULE_ATTR_DELEGATION_ENTRY(&mp_module_sys_attr), - #endif }; STATIC MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table); @@ -317,6 +312,7 @@ MP_REGISTER_ROOT_POINTER(mp_obj_t sys_exitfunc); #if MICROPY_PY_SYS_ATTR_DELEGATION // Contains mutable sys attributes. MP_REGISTER_ROOT_POINTER(mp_obj_t sys_mutable[MP_SYS_MUTABLE_NUM]); +MP_REGISTER_MODULE_DELEGATION(mp_module_sys, &mp_module_sys_attr); #endif #endif // MICROPY_PY_SYS diff --git a/py/mpconfig.h b/py/mpconfig.h index a004f548ad9..504ad64b012 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -839,8 +839,8 @@ typedef double mp_float_t; #define MICROPY_STREAMS_POSIX_API (0) #endif -// Whether modules can use MP_MODULE_ATTR_DELEGATION_ENTRY() to delegate failed -// attribute lookups. +// Whether modules can use MP_REGISTER_MODULE_DELEGATION() to delegate failed +// attribute lookups to a custom handler function. #ifndef MICROPY_MODULE_ATTR_DELEGATION #define MICROPY_MODULE_ATTR_DELEGATION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif diff --git a/py/obj.h b/py/obj.h index 005383e9f38..de4c15b22c6 100644 --- a/py/obj.h +++ b/py/obj.h @@ -437,6 +437,10 @@ typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t; // As above, but allow this module to be extended from the filesystem. #define MP_REGISTER_EXTENSIBLE_MODULE(module_name, obj_module) +// Add a custom handler for a builtin module that will be called to delegate +// failed attribute lookups. +#define MP_REGISTER_MODULE_DELEGATION(obj_module, fun_name) + // Declare a root pointer (to avoid garbage collection of a global static variable). // param variable_declaration: a valid C variable declaration #define MP_REGISTER_ROOT_POINTER(variable_declaration) diff --git a/py/objmodule.c b/py/objmodule.c index bf383662667..ad96a3be287 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -63,20 +63,7 @@ STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kin mp_printf(print, "", module_name); } -STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - #if MICROPY_MODULE_ATTR_DELEGATION - // Delegate lookup to a module's custom attr method (found in last lot of globals dict). - mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); - mp_map_t *map = &self->globals->map; - if (map->table[map->alloc - 1].key == MP_OBJ_NEW_QSTR(MP_QSTRnull)) { - ((mp_attr_fun_t)MP_OBJ_TO_PTR(map->table[map->alloc - 1].value))(self_in, attr, dest); - } - #else - (void)self_in; - (void)attr; - (void)dest; - #endif -} +STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest); STATIC void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); @@ -177,6 +164,18 @@ STATIC const mp_rom_map_elem_t mp_builtin_extensible_module_table[] = { }; MP_DEFINE_CONST_MAP(mp_builtin_extensible_module_map, mp_builtin_extensible_module_table); +#if MICROPY_MODULE_ATTR_DELEGATION && defined(MICROPY_MODULE_DELEGATIONS) +typedef struct _mp_module_delegation_entry_t { + mp_rom_obj_t mod; + mp_attr_fun_t fun; +} mp_module_delegation_entry_t; + +STATIC const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] = { + // delegation entries declared with MP_REGISTER_MODULE_DELEGATION() + MICROPY_MODULE_DELEGATIONS +}; +#endif + // 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) { @@ -230,6 +229,23 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) { return elem->value; } +STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { + #if MICROPY_MODULE_ATTR_DELEGATION + // Delegate lookup to a module's custom attr method. + size_t n = MP_ARRAY_SIZE(mp_builtin_module_delegation_table); + for (size_t i = 0; i < n; ++i) { + if (*(mp_obj_t *)(&mp_builtin_module_delegation_table[i].mod) == self_in) { + mp_builtin_module_delegation_table[i].fun(self_in, attr, dest); + break; + } + } + #else + (void)self_in; + (void)attr; + (void)dest; + #endif +} + void mp_module_generic_attr(qstr attr, mp_obj_t *dest, const uint16_t *keys, mp_obj_t *values) { for (size_t i = 0; keys[i] != MP_QSTRnull; ++i) { if (attr == keys[i]) { diff --git a/py/objmodule.h b/py/objmodule.h index 63ae3c3bdfa..9cc9a2f102f 100644 --- a/py/objmodule.h +++ b/py/objmodule.h @@ -28,9 +28,6 @@ #include "py/obj.h" -// Place at the very end of a module's globals_table. -#define MP_MODULE_ATTR_DELEGATION_ENTRY(ptr) { MP_ROM_QSTR(MP_QSTRnull), MP_ROM_PTR(ptr) } - extern const mp_map_t mp_builtin_module_map; extern const mp_map_t mp_builtin_extensible_module_map; From e6926d60219d9b00da3eedb5eedecefe0d6c321c Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Tue, 6 Jun 2023 22:49:50 +1000 Subject: [PATCH 0019/4300] py/objmodule: Workaround for MSVC with no module delegation. When compiling mpy-cross, there is no `sys` module, and so there will be no entries in the `mp_builtin_module_delegation_table`. MSVC doesn't like this, so instead pretend as if the feature isn't enabled at all. Signed-off-by: Jim Mussared --- py/makemoduledefs.py | 3 +++ py/objmodule.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/py/makemoduledefs.py b/py/makemoduledefs.py index 5a1362a4c98..b1e118bf374 100644 --- a/py/makemoduledefs.py +++ b/py/makemoduledefs.py @@ -103,6 +103,9 @@ def generate_module_table_header(modules): def generate_module_delegations(delegations): + if not delegations: + return + print("\n#define MICROPY_MODULE_DELEGATIONS \\") for obj_module, fun_name in delegations: print( diff --git a/py/objmodule.c b/py/objmodule.c index ad96a3be287..8ffae139bca 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -230,7 +230,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) { } STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - #if MICROPY_MODULE_ATTR_DELEGATION + #if MICROPY_MODULE_ATTR_DELEGATION && defined(MICROPY_MODULE_DELEGATIONS) // Delegate lookup to a module's custom attr method. size_t n = MP_ARRAY_SIZE(mp_builtin_module_delegation_table); for (size_t i = 0; i < n; ++i) { From 7d2ee8aed0cc5ba1a0041ac4cc7631898aaf252f Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Mon, 5 Jun 2023 22:38:36 +1000 Subject: [PATCH 0020/4300] py/mpconfig: Enable module delegation if sys needs it. Otherwise you can get into the confusing state where e.g. sys.ps1 is enabled in config (via `MICROPY_PY_SYS_PS1_PS2`) but still doesn't actually get enabled. Also verify that the required delegation options are enabled in modsys.c. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- ports/esp8266/mpconfigport.h | 1 - py/modsys.c | 14 ++++++++++++++ py/mpconfig.h | 2 +- py/mpstate.h | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h index 37a794f44b2..18b2e47e29d 100644 --- a/ports/esp8266/mpconfigport.h +++ b/ports/esp8266/mpconfigport.h @@ -19,7 +19,6 @@ #define MICROPY_OPT_MATH_FACTORIAL (0) #define MICROPY_REPL_EMACS_KEYS (0) #define MICROPY_PY_BUILTINS_COMPLEX (0) -#define MICROPY_MODULE_ATTR_DELEGATION (0) #define MICROPY_PY_FUNCTION_ATTRS (0) #define MICROPY_PY_DELATTR_SETATTR (0) #define MICROPY_PY_BUILTINS_STR_CENTER (0) diff --git a/py/modsys.c b/py/modsys.c index a0ecb87b5f3..72817ce0093 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -195,7 +195,21 @@ STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) { MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace); #endif // MICROPY_PY_SYS_SETTRACE + +#if MICROPY_PY_SYS_PS1_PS2 && !MICROPY_PY_SYS_ATTR_DELEGATION +#error "MICROPY_PY_SYS_PS1_PS2 requires MICROPY_PY_SYS_ATTR_DELEGATION" +#endif + +#if MICROPY_PY_SYS_TRACEBACKLIMIT && !MICROPY_PY_SYS_ATTR_DELEGATION +#error "MICROPY_PY_SYS_TRACEBACKLIMIT requires MICROPY_PY_SYS_ATTR_DELEGATION" +#endif + +#if MICROPY_PY_SYS_ATTR_DELEGATION && !MICROPY_MODULE_ATTR_DELEGATION +#error "MICROPY_PY_SYS_ATTR_DELEGATION requires MICROPY_MODULE_ATTR_DELEGATION" +#endif + #if MICROPY_PY_SYS_ATTR_DELEGATION +// Must be kept in sync with the enum at the top of mpstate.h. STATIC const uint16_t sys_mutable_keys[] = { #if MICROPY_PY_SYS_PS1_PS2 MP_QSTR_ps1, diff --git a/py/mpconfig.h b/py/mpconfig.h index 504ad64b012..b6f8838662d 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -842,7 +842,7 @@ typedef double mp_float_t; // Whether modules can use MP_REGISTER_MODULE_DELEGATION() to delegate failed // attribute lookups to a custom handler function. #ifndef MICROPY_MODULE_ATTR_DELEGATION -#define MICROPY_MODULE_ATTR_DELEGATION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#define MICROPY_MODULE_ATTR_DELEGATION (MICROPY_PY_SYS_ATTR_DELEGATION || MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to call __init__ when importing builtin modules for the first time. diff --git a/py/mpstate.h b/py/mpstate.h index 80b49cb6b64..3786131de6b 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -40,6 +40,8 @@ // memory system, runtime and virtual machine. The state is a global // variable, but in the future it is hoped that the state can become local. +#if MICROPY_PY_SYS_ATTR_DELEGATION +// Must be kept in sync with sys_mutable_keys in modsys.c. enum { #if MICROPY_PY_SYS_PS1_PS2 MP_SYS_MUTABLE_PS1, @@ -50,6 +52,7 @@ enum { #endif MP_SYS_MUTABLE_NUM, }; +#endif // MICROPY_PY_SYS_ATTR_DELEGATION // This structure contains dynamic configuration for the compiler. #if MICROPY_DYNAMIC_COMPILER From 5e50975a6dd9466afafbcd012c00078093fe1f57 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Mon, 5 Jun 2023 16:52:29 +1000 Subject: [PATCH 0021/4300] py/modsys: Allow sys.path to be assigned to. Previously sys.path could be modified by append/pop or slice assignment. This allows `sys.path = [...]`, which can be simpler in many cases, but also improves CPython compatibility. It also allows sys.path to be set to a tuple which means that you can clear sys.path (e.g. temporarily) with no allocations. This also makes sys.path (and sys.argv for consistency) able to be disabled via mpconfig. The unix port (and upytesthelper) require them, so they explicitly verify that they're enabled. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- ports/unix/main.c | 66 +++++++++++++++------------- ports/unix/mpconfigport.h | 2 +- py/builtinimport.c | 4 +- py/modsys.c | 18 ++++++-- py/mpconfig.h | 19 +++++++- py/mpstate.h | 3 ++ py/runtime.c | 6 ++- py/runtime.h | 7 ++- shared/upytesthelper/upytesthelper.c | 10 ++++- 9 files changed, 93 insertions(+), 42 deletions(-) diff --git a/ports/unix/main.c b/ports/unix/main.c index 16f663de199..b065706ba65 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -69,6 +69,14 @@ long heap_size = 1024 * 1024 * (sizeof(mp_uint_t) / 4); #define MICROPY_GC_SPLIT_HEAP_N_HEAPS (1) #endif +#if !MICROPY_PY_SYS_PATH +#error "The unix port requires MICROPY_PY_SYS_PATH=1" +#endif + +#if !MICROPY_PY_SYS_ARGV +#error "The unix port requires MICROPY_PY_SYS_ARGV=1" +#endif + STATIC void stderr_print_strn(void *env, const char *str, size_t len) { (void)env; ssize_t ret; @@ -538,44 +546,40 @@ MP_NOINLINE int main_(int argc, char **argv) { } #endif - char *home = getenv("HOME"); - char *path = getenv("MICROPYPATH"); - if (path == NULL) { - path = MICROPY_PY_SYS_PATH_DEFAULT; - } - size_t path_num = 1; // [0] is for current dir (or base dir of the script) - if (*path == PATHLIST_SEP_CHAR) { - path_num++; - } - for (char *p = path; p != NULL; p = strchr(p, PATHLIST_SEP_CHAR)) { - path_num++; - if (p != NULL) { - p++; - } - } - mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_path), path_num); - mp_obj_t *path_items; - mp_obj_list_get(mp_sys_path, &path_num, &path_items); - path_items[0] = MP_OBJ_NEW_QSTR(MP_QSTR_); { - char *p = path; - for (mp_uint_t i = 1; i < path_num; i++) { - char *p1 = strchr(p, PATHLIST_SEP_CHAR); - if (p1 == NULL) { - p1 = p + strlen(p); + // sys.path starts as [""] + mp_sys_path = mp_obj_new_list(0, NULL); + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); + + // Add colon-separated entries from MICROPYPATH. + char *home = getenv("HOME"); + char *path = getenv("MICROPYPATH"); + if (path == NULL) { + path = MICROPY_PY_SYS_PATH_DEFAULT; + } + if (*path == PATHLIST_SEP_CHAR) { + // First entry is empty. We've already added an empty entry to sys.path, so skip it. + ++path; + } + bool path_remaining = *path; + while (path_remaining) { + char *path_entry_end = strchr(path, PATHLIST_SEP_CHAR); + if (path_entry_end == NULL) { + path_entry_end = path + strlen(path); + path_remaining = false; } - if (p[0] == '~' && p[1] == '/' && home != NULL) { + if (path[0] == '~' && path[1] == '/' && home != NULL) { // Expand standalone ~ to $HOME int home_l = strlen(home); vstr_t vstr; - vstr_init(&vstr, home_l + (p1 - p - 1) + 1); + vstr_init(&vstr, home_l + (path_entry_end - path - 1) + 1); vstr_add_strn(&vstr, home, home_l); - vstr_add_strn(&vstr, p + 1, p1 - p - 1); - path_items[i] = mp_obj_new_str_from_vstr(&vstr); + vstr_add_strn(&vstr, path + 1, path_entry_end - path - 1); + mp_obj_list_append(mp_sys_path, mp_obj_new_str_from_vstr(&vstr)); } else { - path_items[i] = mp_obj_new_str_via_qstr(p, p1 - p); + mp_obj_list_append(mp_sys_path, mp_obj_new_str_via_qstr(path, path_entry_end - path)); } - p = p1 + 1; + path = path_entry_end + 1; } } @@ -710,7 +714,7 @@ MP_NOINLINE int main_(int argc, char **argv) { // Set base dir of the script as first entry in sys.path. char *p = strrchr(basedir, '/'); - path_items[0] = mp_obj_new_str_via_qstr(basedir, p - basedir); + mp_obj_list_store(mp_sys_path, MP_OBJ_NEW_SMALL_INT(0), mp_obj_new_str_via_qstr(basedir, p - basedir)); free(pathbuf); set_sys_argv(argv, argc, a); diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index 58aba9700bd..c20aff1683c 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -154,7 +154,7 @@ typedef long mp_off_t; // Ensure builtinimport.c works with -m. #define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (1) -// Don't default sys.argv because we do that in main. +// Don't default sys.argv and sys.path because we do that in main. #define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (0) // Enable sys.executable. diff --git a/py/builtinimport.c b/py/builtinimport.c index 8a125fc538a..4fee04b8f34 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -118,7 +118,7 @@ STATIC mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) { #if MICROPY_PY_SYS size_t path_num; mp_obj_t *path_items; - mp_obj_list_get(mp_sys_path, &path_num, &path_items); + mp_obj_get_array(mp_sys_path, &path_num, &path_items); // go through each sys.path entry, trying to import "/". for (size_t i = 0; i < path_num; i++) { @@ -365,7 +365,7 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, // which may have come from the filesystem. size_t path_num; mp_obj_t *path_items; - mp_obj_list_get(mp_sys_path, &path_num, &path_items); + mp_obj_get_array(mp_sys_path, &path_num, &path_items); if (path_num) #endif { diff --git a/py/modsys.c b/py/modsys.c index 72817ce0093..9b3a2bc1635 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -195,6 +195,9 @@ STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) { MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace); #endif // MICROPY_PY_SYS_SETTRACE +#if MICROPY_PY_SYS_PATH && !MICROPY_PY_SYS_ATTR_DELEGATION +#error "MICROPY_PY_SYS_PATH requires MICROPY_PY_SYS_ATTR_DELEGATION" +#endif #if MICROPY_PY_SYS_PS1_PS2 && !MICROPY_PY_SYS_ATTR_DELEGATION #error "MICROPY_PY_SYS_PS1_PS2 requires MICROPY_PY_SYS_ATTR_DELEGATION" @@ -211,6 +214,11 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace); #if MICROPY_PY_SYS_ATTR_DELEGATION // Must be kept in sync with the enum at the top of mpstate.h. STATIC const uint16_t sys_mutable_keys[] = { + #if MICROPY_PY_SYS_PATH + // Code should access this (as an mp_obj_t) for use with e.g. + // mp_obj_list_append by using the `mp_sys_path` macro defined in runtime.h. + MP_QSTR_path, + #endif #if MICROPY_PY_SYS_PS1_PS2 MP_QSTR_ps1, MP_QSTR_ps2, @@ -231,8 +239,9 @@ void mp_module_sys_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys) }, - { MP_ROM_QSTR(MP_QSTR_path), MP_ROM_PTR(&MP_STATE_VM(mp_sys_path_obj)) }, + #if MICROPY_PY_SYS_ARGV { MP_ROM_QSTR(MP_QSTR_argv), MP_ROM_PTR(&MP_STATE_VM(mp_sys_argv_obj)) }, + #endif { MP_ROM_QSTR(MP_QSTR_version), MP_ROM_PTR(&mp_sys_version_obj) }, { MP_ROM_QSTR(MP_QSTR_version_info), MP_ROM_PTR(&mp_sys_version_info_obj) }, { MP_ROM_QSTR(MP_QSTR_implementation), MP_ROM_PTR(&mp_sys_implementation_obj) }, @@ -308,10 +317,11 @@ const mp_obj_module_t mp_module_sys = { // available. MP_REGISTER_MODULE(MP_QSTR_sys, mp_module_sys); -// If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is not enabled then these two lists -// must be initialised after the call to mp_init. -MP_REGISTER_ROOT_POINTER(mp_obj_list_t mp_sys_path_obj); +#if MICROPY_PY_SYS_ARGV +// Code should access this (as an mp_obj_t) for use with e.g. +// mp_obj_list_append by using the `mp_sys_argv` macro defined in runtime.h. MP_REGISTER_ROOT_POINTER(mp_obj_list_t mp_sys_argv_obj); +#endif #if MICROPY_PY_SYS_EXC_INFO // current exception being handled, for sys.exc_info() diff --git a/py/mpconfig.h b/py/mpconfig.h index b6f8838662d..eb23c5965c3 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1421,6 +1421,23 @@ typedef double mp_float_t; #define MICROPY_PY_SYS_ATEXIT (0) #endif +// Whether to provide the "sys.path" attribute (which forces module delegation +// and mutable sys attributes to be enabled). +// If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled, this is initialised in +// mp_init to an empty list. Otherwise the port must initialise it using +// `mp_sys_path = mp_obj_new_list(...)`. +#ifndef MICROPY_PY_SYS_PATH +#define MICROPY_PY_SYS_PATH (1) +#endif + +// Whether to provide the "sys.argv" attribute. +// If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled, this is initialised in +// mp_init to an empty list. Otherwise the port must initialise it using +// `mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_argv), ...);` +#ifndef MICROPY_PY_SYS_ARGV +#define MICROPY_PY_SYS_ARGV (1) +#endif + // Whether to provide sys.{ps1,ps2} mutable attributes, to control REPL prompts #ifndef MICROPY_PY_SYS_PS1_PS2 #define MICROPY_PY_SYS_PS1_PS2 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) @@ -1455,7 +1472,7 @@ typedef double mp_float_t; // Whether the sys module supports attribute delegation // This is enabled automatically when needed by other features #ifndef MICROPY_PY_SYS_ATTR_DELEGATION -#define MICROPY_PY_SYS_ATTR_DELEGATION (MICROPY_PY_SYS_PS1_PS2 || MICROPY_PY_SYS_TRACEBACKLIMIT) +#define MICROPY_PY_SYS_ATTR_DELEGATION (MICROPY_PY_SYS_PATH || MICROPY_PY_SYS_PS1_PS2 || MICROPY_PY_SYS_TRACEBACKLIMIT) #endif // Whether to provide "errno" module diff --git a/py/mpstate.h b/py/mpstate.h index 3786131de6b..080dc1380bc 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -43,6 +43,9 @@ #if MICROPY_PY_SYS_ATTR_DELEGATION // Must be kept in sync with sys_mutable_keys in modsys.c. enum { + #if MICROPY_PY_SYS_PATH + MP_SYS_MUTABLE_PATH, + #endif #if MICROPY_PY_SYS_PS1_PS2 MP_SYS_MUTABLE_PS1, MP_SYS_MUTABLE_PS2, diff --git a/py/runtime.c b/py/runtime.c index 2326dfb3cac..f5d219728f7 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -136,13 +136,17 @@ void mp_init(void) { #endif #if MICROPY_PY_SYS_PATH_ARGV_DEFAULTS - mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_path), 0); + #if MICROPY_PY_SYS_PATH + mp_sys_path = mp_obj_new_list(0, NULL); mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script) #if MICROPY_MODULE_FROZEN mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen)); #endif + #endif + #if MICROPY_PY_SYS_ARGV mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_argv), 0); #endif + #endif // MICROPY_PY_SYS_PATH_ARGV_DEFAULTS #if MICROPY_PY_SYS_ATEXIT MP_STATE_VM(sys_exitfunc) = mp_const_none; diff --git a/py/runtime.h b/py/runtime.h index 78194973d61..c033c77b403 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -227,8 +227,13 @@ int mp_native_type_from_qstr(qstr qst); mp_uint_t mp_native_from_obj(mp_obj_t obj, mp_uint_t type); mp_obj_t mp_native_to_obj(mp_uint_t val, mp_uint_t type); -#define mp_sys_path (MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_sys_path_obj))) +#if MICROPY_PY_SYS_PATH +#define mp_sys_path (MP_STATE_VM(sys_mutable[MP_SYS_MUTABLE_PATH])) +#endif + +#if MICROPY_PY_SYS_ARGV #define mp_sys_argv (MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_sys_argv_obj))) +#endif #if MICROPY_WARNINGS #ifndef mp_warning diff --git a/shared/upytesthelper/upytesthelper.c b/shared/upytesthelper/upytesthelper.c index 12fa8276b0b..ba20037f7ac 100644 --- a/shared/upytesthelper/upytesthelper.c +++ b/shared/upytesthelper/upytesthelper.c @@ -31,6 +31,14 @@ #include "py/compile.h" #include "upytesthelper.h" +#if !MICROPY_PY_SYS_PATH +#error "upytesthelper requires MICROPY_PY_SYS_PATH=1" +#endif + +#if !MICROPY_PY_SYS_ARGV +#error "upytesthelper requires MICROPY_PY_SYS_ARGV=1" +#endif + static const char *test_exp_output; static int test_exp_output_len, test_rem_output_len; static int test_failed; @@ -93,7 +101,7 @@ void upytest_execute_test(const char *src) { // reinitialized before running each. gc_init(heap_start, heap_end); mp_init(); - mp_obj_list_init(mp_sys_path, 0); + mp_sys_path = mp_obj_new_list(0, NULL); #if MICROPY_MODULE_FROZEN mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen)); #endif From 4216bc7d1351feb8199e4ebbff1a9598aa1c5b02 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 18 Aug 2022 16:57:45 +1000 Subject: [PATCH 0022/4300] tests: Replace umodule with module everywhere. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- ports/unix/coverage.c | 14 +-- tests/basics/array1.py | 9 +- tests/basics/array_add.py | 9 +- tests/basics/array_construct.py | 9 +- tests/basics/array_construct2.py | 9 +- tests/basics/array_construct_endian.py | 9 +- tests/basics/array_intbig.py | 9 +- tests/basics/array_micropython.py | 9 +- tests/basics/async_await2.py | 5 +- tests/basics/async_for2.py | 5 +- tests/basics/async_with2.py | 5 +- tests/basics/attrtuple1.py | 5 +- tests/basics/builtin_callable.py | 5 +- tests/basics/builtin_dir.py | 5 +- tests/basics/bytearray_construct_array.py | 9 +- tests/basics/bytearray_construct_endian.py | 9 +- tests/basics/bytes_add_array.py | 9 +- tests/basics/bytes_add_endian.py | 9 +- tests/basics/bytes_compare_array.py | 9 +- tests/basics/bytes_construct_array.py | 9 +- tests/basics/bytes_construct_endian.py | 9 +- tests/basics/class_ordereddict.py | 9 +- tests/basics/class_store_class.py | 7 +- tests/basics/deque1.py | 5 +- tests/basics/deque2.py | 5 +- tests/basics/dict_fixed.py | 22 ++-- tests/basics/errno1.py | 14 +-- tests/basics/errno1.py.exp | 2 +- tests/basics/int_big1.py | 5 +- tests/basics/io_buffered_writer.py | 2 +- tests/basics/io_bytesio_cow.py | 6 +- tests/basics/io_bytesio_ext.py | 6 +- tests/basics/io_bytesio_ext2.py | 6 +- tests/basics/io_iobase.py | 6 +- tests/basics/io_stringio1.py | 6 +- tests/basics/io_stringio_base.py | 5 +- tests/basics/io_stringio_with.py | 6 +- tests/basics/io_write_ext.py | 6 +- tests/basics/memoryview1.py | 9 +- tests/basics/memoryview2.py | 9 +- tests/basics/memoryview_intbig.py | 9 +- tests/basics/memoryview_itemsize.py | 9 +- tests/basics/memoryview_slice_assign.py | 9 +- tests/basics/module2.py | 4 +- tests/basics/namedtuple1.py | 5 +- tests/basics/namedtuple_asdict.py | 5 +- tests/basics/ordereddict1.py | 7 +- tests/basics/ordereddict_eq.py | 7 +- tests/basics/python34.py | 6 +- tests/basics/string_compare.py | 5 +- tests/basics/struct1.py | 11 +- tests/basics/struct1_intbig.py | 11 +- tests/basics/struct2.py | 13 +-- tests/basics/struct_endian.py | 13 +-- tests/basics/struct_micropython.py | 11 +- tests/basics/subclass_native_call.py | 5 +- tests/basics/subclass_native_exc_new.py | 1 - tests/basics/sys1.py | 6 +- tests/basics/sys_exit.py | 6 +- tests/basics/sys_getsizeof.py | 7 +- tests/basics/sys_path.py | 6 +- tests/basics/sys_tracebacklimit.py | 8 +- tests/basics/sys_tracebacklimit.py.exp | 30 ++--- tests/cmdline/repl_micropyinspect | 4 +- tests/cmdline/repl_sys_ps1_ps2.py | 6 +- tests/cmdline/repl_sys_ps1_ps2.py.exp | 6 +- tests/esp32/partition_ota.py | 12 +- tests/esp32/resolve_on_connect.py | 5 +- ...i_a2b_base64.py => binascii_a2b_base64.py} | 5 +- ...i_b2a_base64.py => binascii_b2a_base64.py} | 5 +- .../{ubinascii_crc32.py => binascii_crc32.py} | 5 +- ...inascii_hexlify.py => binascii_hexlify.py} | 5 +- ...cii_unhexlify.py => binascii_unhexlify.py} | 5 +- tests/extmod/btree1.py | 8 +- tests/extmod/btree_error.py | 14 ++- tests/extmod/btree_gc.py | 4 +- ..._aes128_cbc.py => cryptolib_aes128_cbc.py} | 2 +- ...cbc.py.exp => cryptolib_aes128_cbc.py.exp} | 0 ..._aes128_ctr.py => cryptolib_aes128_ctr.py} | 2 +- ...ctr.py.exp => cryptolib_aes128_ctr.py.exp} | 0 ..._aes128_ecb.py => cryptolib_aes128_ecb.py} | 2 +- ...ecb.py.exp => cryptolib_aes128_ecb.py.exp} | 0 ...ecb_enc.py => cryptolib_aes128_ecb_enc.py} | 2 +- ...py.exp => cryptolib_aes128_ecb_enc.py.exp} | 0 ...b_inpl.py => cryptolib_aes128_ecb_inpl.py} | 2 +- ...y.exp => cryptolib_aes128_ecb_inpl.py.exp} | 0 ...b_into.py => cryptolib_aes128_ecb_into.py} | 2 +- ...y.exp => cryptolib_aes128_ecb_into.py.exp} | 0 ..._aes256_cbc.py => cryptolib_aes256_cbc.py} | 2 +- ...cbc.py.exp => cryptolib_aes256_cbc.py.exp} | 0 ..._aes256_ecb.py => cryptolib_aes256_ecb.py} | 2 +- ...ecb.py.exp => cryptolib_aes256_ecb.py.exp} | 0 tests/extmod/framebuf16.py | 4 +- tests/extmod/framebuf_palette.py | 2 +- tests/extmod/framebuf_subclass.py | 4 +- .../{uhashlib_final.py => hashlib_final.py} | 4 +- ...hlib_final.py.exp => hashlib_final.py.exp} | 0 tests/extmod/hashlib_md5.py | 18 +++ tests/extmod/hashlib_sha1.py | 18 +++ .../{uhashlib_sha256.py => hashlib_sha256.py} | 13 +-- tests/extmod/{uheapq1.py => heapq1.py} | 11 +- tests/extmod/{ujson_dump.py => json_dump.py} | 14 +-- ...son_dump_iobase.py => json_dump_iobase.py} | 12 +- ..._separators.py => json_dump_separators.py} | 14 +-- .../extmod/{ujson_dumps.py => json_dumps.py} | 9 +- tests/extmod/json_dumps_extra.py | 9 ++ ...s_extra.py.exp => json_dumps_extra.py.exp} | 0 tests/extmod/json_dumps_float.py | 8 ++ tests/extmod/json_dumps_ordereddict.py | 8 ++ ...separators.py => json_dumps_separators.py} | 9 +- tests/extmod/json_load.py | 11 ++ .../extmod/{ujson_loads.py => json_loads.py} | 9 +- ...son_loads_bytes.py => json_loads_bytes.py} | 9 +- ...s_bytes.py.exp => json_loads_bytes.py.exp} | 0 ...son_loads_float.py => json_loads_float.py} | 9 +- tests/extmod/machine1.py | 6 +- tests/extmod/machine_pinbase.py | 6 +- tests/extmod/machine_pulse.py | 6 +- tests/extmod/machine_signal.py | 6 +- tests/extmod/machine_timer.py | 6 +- .../{urandom_basic.py => random_basic.py} | 9 +- ...andom_basic.py.exp => random_basic.py.exp} | 0 .../{urandom_extra.py => random_extra.py} | 9 +- ...m_extra_float.py => random_extra_float.py} | 9 +- ...seed_default.py => random_seed_default.py} | 11 +- tests/extmod/{ure1.py => re1.py} | 9 +- tests/extmod/{ure_debug.py => re_debug.py} | 6 +- .../{ure_debug.py.exp => re_debug.py.exp} | 0 tests/extmod/{ure_error.py => re_error.py} | 9 +- tests/extmod/{ure_group.py => re_group.py} | 9 +- tests/extmod/{ure_groups.py => re_groups.py} | 9 +- tests/extmod/{ure_limit.py => re_limit.py} | 4 +- .../{ure_limit.py.exp => re_limit.py.exp} | 0 .../{ure_namedclass.py => re_namedclass.py} | 9 +- tests/extmod/{ure_span.py => re_span.py} | 9 +- tests/extmod/{ure_split.py => re_split.py} | 9 +- .../{ure_split_empty.py => re_split_empty.py} | 2 +- ...lit_empty.py.exp => re_split_empty.py.exp} | 0 ...e_split_notimpl.py => re_split_notimpl.py} | 2 +- ...notimpl.py.exp => re_split_notimpl.py.exp} | 0 tests/extmod/re_stack_overflow.py | 10 ++ ...erflow.py.exp => re_stack_overflow.py.exp} | 0 tests/extmod/{ure_sub.py => re_sub.py} | 9 +- ...e_sub_unmatched.py => re_sub_unmatched.py} | 9 +- ...matched.py.exp => re_sub_unmatched.py.exp} | 0 ...ect_poll_basic.py => select_poll_basic.py} | 15 +-- ...uselect_poll_udp.py => select_poll_udp.py} | 13 +-- ...ocket_tcp_basic.py => socket_tcp_basic.py} | 9 +- ...udp_nonblock.py => socket_udp_nonblock.py} | 9 +- tests/extmod/{ussl_basic.py => ssl_basic.py} | 4 +- .../{ussl_basic.py.exp => ssl_basic.py.exp} | 0 .../{ussl_keycert.py => ssl_keycert.py} | 6 +- ...ussl_keycert.py.exp => ssl_keycert.py.exp} | 0 tests/extmod/{ussl_poll.py => ssl_poll.py} | 14 +-- .../{ussl_poll.py.exp => ssl_poll.py.exp} | 0 tests/extmod/ticks_add.py | 2 +- tests/extmod/ticks_diff.py | 2 +- tests/extmod/time_ms_us.py | 26 ++--- tests/extmod/{utime_res.py => time_res.py} | 16 +-- .../{utime_res.py.exp => time_res.py.exp} | 0 .../{utime_time_ns.py => time_time_ns.py} | 14 +-- ...ime_time_ns.py.exp => time_time_ns.py.exp} | 0 tests/extmod/{utimeq1.py => timeq1.py} | 18 +-- .../extmod/{utimeq1.py.exp => timeq1.py.exp} | 0 .../{utimeq_stable.py => timeq_stable.py} | 4 +- ...imeq_stable.py.exp => timeq_stable.py.exp} | 0 tests/extmod/uasyncio_basic.py | 13 +-- tests/extmod/uasyncio_micropython.py | 8 +- tests/extmod/uasyncio_threadsafeflag.py | 2 +- tests/extmod/uasyncio_wait_task.py | 12 +- .../extmod/uctypes_array_assign_native_le.py | 4 +- .../uctypes_array_assign_native_le_intbig.py | 4 +- tests/extmod/uctypes_native_le.py | 4 +- tests/extmod/uctypes_ptr_le.py | 4 +- tests/extmod/uctypes_ptr_native_le.py | 4 +- tests/extmod/uctypes_sizeof_od.py | 2 +- tests/extmod/uhashlib_md5.py | 21 ---- tests/extmod/uhashlib_sha1.py | 21 ---- tests/extmod/ujson_dumps_extra.py | 9 -- tests/extmod/ujson_dumps_float.py | 11 -- tests/extmod/ujson_dumps_ordereddict.py | 12 -- tests/extmod/ujson_load.py | 15 --- tests/extmod/ure_stack_overflow.py | 13 --- tests/extmod/vfs_basic.py | 104 +++++++++--------- tests/extmod/vfs_blockdev.py | 12 +- tests/extmod/vfs_fat_fileio1.py | 24 ++-- tests/extmod/vfs_fat_fileio2.py | 26 ++--- tests/extmod/vfs_fat_finaliser.py | 12 +- tests/extmod/vfs_fat_ilistdir_del.py | 6 +- tests/extmod/vfs_fat_more.py | 94 ++++++++-------- tests/extmod/vfs_fat_mtime.py | 14 +-- tests/extmod/vfs_fat_oldproto.py | 12 +- tests/extmod/vfs_fat_ramdisk.py | 22 ++-- tests/extmod/vfs_fat_ramdisklarge.py | 12 +- tests/extmod/vfs_lfs.py | 10 +- tests/extmod/vfs_lfs_corrupt.py | 10 +- tests/extmod/vfs_lfs_error.py | 10 +- tests/extmod/vfs_lfs_file.py | 10 +- tests/extmod/vfs_lfs_ilistdir_del.py | 6 +- tests/extmod/vfs_lfs_mount.py | 42 +++---- tests/extmod/vfs_lfs_mtime.py | 16 +-- tests/extmod/vfs_lfs_superblock.py | 12 +- tests/extmod/vfs_posix.py | 48 ++++---- tests/extmod/vfs_userfs.py | 22 ++-- tests/extmod/websocket_basic.py | 22 ++-- .../{uzlib_decompio.py => zlib_decompio.py} | 4 +- ...b_decompio.py.exp => zlib_decompio.py.exp} | 0 ...lib_decompio_gz.py => zlib_decompio_gz.py} | 4 +- ...mpio_gz.py.exp => zlib_decompio_gz.py.exp} | 0 ...uzlib_decompress.py => zlib_decompress.py} | 7 +- tests/feature_check/byteorder.py | 5 +- .../{uio_module.py => io_module.py} | 4 +- .../{uio_module.py.exp => io_module.py.exp} | 0 tests/float/array_construct.py | 9 +- tests/float/bytearray_construct_endian.py | 9 +- tests/float/bytes_construct_endian.py | 9 +- tests/float/float2int_doubleprec_intbig.py | 8 +- tests/float/float2int_fp30_intbig.py | 8 +- tests/float/float2int_intbig.py | 8 +- tests/float/float_array.py | 9 +- tests/float/float_struct.py | 5 +- tests/import/builtin_ext.py | 4 + tests/import/builtin_ext.py.exp | 4 +- tests/import/ext/time.py | 6 +- tests/inlineasm/asmfpldrstr.py | 2 +- tests/inlineasm/asmsum.py | 2 +- tests/internal_bench/var-8-namedtuple-1st.py | 2 +- .../internal_bench/var-8.1-namedtuple-5th.py | 2 +- tests/io/argv.py | 5 +- tests/io/builtin_print_file.py | 5 +- tests/io/file_stdio.py | 5 +- tests/io/open_append.py | 5 +- tests/io/open_plus.py | 5 +- tests/micropython/builtin_execfile.py | 22 ++-- tests/micropython/emg_exc.py | 8 +- tests/micropython/heapalloc_bytesio.py | 4 +- tests/micropython/heapalloc_bytesio2.py | 4 +- tests/micropython/heapalloc_iter.py | 9 +- tests/micropython/heapalloc_traceback.py | 8 +- tests/micropython/import_mpy_invalid.py | 16 +-- tests/micropython/import_mpy_native.py | 20 ++-- tests/micropython/import_mpy_native_gc.py | 12 +- tests/micropython/opt_level_lineno.py | 2 +- tests/micropython/viper_misc_intbig.py | 4 +- tests/misc/non_compliant.py | 8 +- tests/misc/print_exception.py | 8 +- tests/misc/sys_atexit.py | 6 +- tests/misc/sys_exc_info.py | 5 +- tests/multi_net/ssl_cert_rsa.py | 2 +- tests/multi_net/ssl_data.py | 2 +- tests/multi_net/uasyncio_tcp_readinto.py | 9 +- tests/net_hosted/accept_nonblock.py | 5 +- tests/net_hosted/accept_timeout.py | 5 +- tests/net_hosted/connect_nonblock.py | 6 +- tests/net_hosted/connect_nonblock_xfer.py | 7 +- tests/net_hosted/connect_poll.py | 5 +- tests/net_hosted/ssl_getpeercert.py | 8 +- tests/net_inet/getaddrinfo.py | 5 +- tests/net_inet/ssl_cert.py | 6 +- tests/net_inet/ssl_errors.py | 7 +- tests/net_inet/test_tls_nonblock.py | 5 +- tests/net_inet/test_tls_sites.py | 19 ++-- tests/net_inet/tls_num_errors.py | 6 +- tests/net_inet/tls_text_errors.py | 5 +- tests/perf_bench/benchrun.py | 6 +- tests/perf_bench/bm_hexiom.py | 5 +- tests/perf_bench/core_import_mpy_multi.py | 12 +- tests/perf_bench/core_import_mpy_single.py | 10 +- tests/renesas-ra/freq.py | 2 +- tests/run-natmodtests.py | 18 +-- tests/run-tests-exp.py | 4 +- tests/run-tests.py | 32 +++--- tests/stress/recursive_data.py | 2 +- tests/thread/stress_aes.py | 5 +- tests/thread/stress_create.py | 11 +- tests/thread/stress_heap.py | 5 +- tests/thread/stress_schedule.py | 8 +- tests/thread/thread_exc2.py | 4 +- tests/thread/thread_exit1.py | 5 +- tests/thread/thread_exit2.py | 5 +- tests/thread/thread_lock2.py | 5 +- tests/thread/thread_lock4.py | 5 +- tests/thread/thread_qstr1.py | 5 +- tests/thread/thread_sleep1.py | 10 +- tests/thread/thread_stacksize1.py | 6 +- tests/thread/thread_start1.py | 5 +- tests/thread/thread_start2.py | 5 +- tests/unicode/unicode_ure.py | 9 +- tests/unix/extra_coverage.py | 10 +- tests/unix/extra_coverage.py.exp | 24 ++-- tests/unix/ffi_types.py | 6 +- .../{time.py => time_mktime_localtime.py} | 5 +- tests/wipy/wlan/machine.py.exp | 2 +- tools/ci.sh | 4 +- tools/tinytest-codegen.py | 6 +- 295 files changed, 1009 insertions(+), 1431 deletions(-) rename tests/extmod/{ubinascii_a2b_base64.py => binascii_a2b_base64.py} (92%) rename tests/extmod/{ubinascii_b2a_base64.py => binascii_b2a_base64.py} (88%) rename tests/extmod/{ubinascii_crc32.py => binascii_crc32.py} (87%) rename tests/extmod/{ubinascii_hexlify.py => binascii_hexlify.py} (80%) rename tests/extmod/{ubinascii_unhexlify.py => binascii_unhexlify.py} (81%) rename tests/extmod/{ucryptolib_aes128_cbc.py => cryptolib_aes128_cbc.py} (90%) rename tests/extmod/{ucryptolib_aes128_cbc.py.exp => cryptolib_aes128_cbc.py.exp} (100%) rename tests/extmod/{ucryptolib_aes128_ctr.py => cryptolib_aes128_ctr.py} (94%) rename tests/extmod/{ucryptolib_aes128_ctr.py.exp => cryptolib_aes128_ctr.py.exp} (100%) rename tests/extmod/{ucryptolib_aes128_ecb.py => cryptolib_aes128_ecb.py} (89%) rename tests/extmod/{ucryptolib_aes128_ecb.py.exp => cryptolib_aes128_ecb.py.exp} (100%) rename tests/extmod/{ucryptolib_aes128_ecb_enc.py => cryptolib_aes128_ecb_enc.py} (91%) rename tests/extmod/{ucryptolib_aes128_ecb_enc.py.exp => cryptolib_aes128_ecb_enc.py.exp} (100%) rename tests/extmod/{ucryptolib_aes128_ecb_inpl.py => cryptolib_aes128_ecb_inpl.py} (90%) rename tests/extmod/{ucryptolib_aes128_ecb_inpl.py.exp => cryptolib_aes128_ecb_inpl.py.exp} (100%) rename tests/extmod/{ucryptolib_aes128_ecb_into.py => cryptolib_aes128_ecb_into.py} (90%) rename tests/extmod/{ucryptolib_aes128_ecb_into.py.exp => cryptolib_aes128_ecb_into.py.exp} (100%) rename tests/extmod/{ucryptolib_aes256_cbc.py => cryptolib_aes256_cbc.py} (90%) rename tests/extmod/{ucryptolib_aes256_cbc.py.exp => cryptolib_aes256_cbc.py.exp} (100%) rename tests/extmod/{ucryptolib_aes256_ecb.py => cryptolib_aes256_ecb.py} (89%) rename tests/extmod/{ucryptolib_aes256_ecb.py.exp => cryptolib_aes256_ecb.py.exp} (100%) rename tests/extmod/{uhashlib_final.py => hashlib_final.py} (92%) rename tests/extmod/{uhashlib_final.py.exp => hashlib_final.py.exp} (100%) create mode 100644 tests/extmod/hashlib_md5.py create mode 100644 tests/extmod/hashlib_sha1.py rename tests/extmod/{uhashlib_sha256.py => hashlib_sha256.py} (72%) rename tests/extmod/{uheapq1.py => heapq1.py} (78%) rename tests/extmod/{ujson_dump.py => json_dump.py} (69%) rename tests/extmod/{ujson_dump_iobase.py => json_dump_iobase.py} (71%) rename tests/extmod/{ujson_dump_separators.py => json_dump_separators.py} (86%) rename tests/extmod/{ujson_dumps.py => json_dumps.py} (83%) create mode 100644 tests/extmod/json_dumps_extra.py rename tests/extmod/{ujson_dumps_extra.py.exp => json_dumps_extra.py.exp} (100%) create mode 100644 tests/extmod/json_dumps_float.py create mode 100644 tests/extmod/json_dumps_ordereddict.py rename tests/extmod/{ujson_dumps_separators.py => json_dumps_separators.py} (93%) create mode 100644 tests/extmod/json_load.py rename tests/extmod/{ujson_loads.py => json_loads.py} (92%) rename tests/extmod/{ujson_loads_bytes.py => json_loads_bytes.py} (56%) rename tests/extmod/{ujson_loads_bytes.py.exp => json_loads_bytes.py.exp} (100%) rename tests/extmod/{ujson_loads_float.py => json_loads_float.py} (65%) rename tests/extmod/{urandom_basic.py => random_basic.py} (81%) rename tests/extmod/{urandom_basic.py.exp => random_basic.py.exp} (100%) rename tests/extmod/{urandom_extra.py => random_extra.py} (89%) rename tests/extmod/{urandom_extra_float.py => random_extra_float.py} (72%) rename tests/extmod/{urandom_seed_default.py => random_seed_default.py} (69%) rename tests/extmod/{ure1.py => re1.py} (95%) rename tests/extmod/{ure_debug.py => re_debug.py} (65%) rename tests/extmod/{ure_debug.py.exp => re_debug.py.exp} (100%) rename tests/extmod/{ure_error.py => re_error.py} (73%) rename tests/extmod/{ure_group.py => re_group.py} (81%) rename tests/extmod/{ure_groups.py => re_groups.py} (81%) rename tests/extmod/{ure_limit.py => re_limit.py} (88%) rename tests/extmod/{ure_limit.py.exp => re_limit.py.exp} (100%) rename tests/extmod/{ure_namedclass.py => re_namedclass.py} (85%) rename tests/extmod/{ure_span.py => re_span.py} (85%) rename tests/extmod/{ure_split.py => re_split.py} (82%) rename tests/extmod/{ure_split_empty.py => re_split_empty.py} (95%) rename tests/extmod/{ure_split_empty.py.exp => re_split_empty.py.exp} (100%) rename tests/extmod/{ure_split_notimpl.py => re_split_notimpl.py} (89%) rename tests/extmod/{ure_split_notimpl.py.exp => re_split_notimpl.py.exp} (100%) create mode 100644 tests/extmod/re_stack_overflow.py rename tests/extmod/{ure_stack_overflow.py.exp => re_stack_overflow.py.exp} (100%) rename tests/extmod/{ure_sub.py => re_sub.py} (93%) rename tests/extmod/{ure_sub_unmatched.py => re_sub_unmatched.py} (71%) rename tests/extmod/{ure_sub_unmatched.py.exp => re_sub_unmatched.py.exp} (100%) rename tests/extmod/{uselect_poll_basic.py => select_poll_basic.py} (69%) rename tests/extmod/{uselect_poll_udp.py => select_poll_udp.py} (66%) rename tests/extmod/{usocket_tcp_basic.py => socket_tcp_basic.py} (60%) rename tests/extmod/{usocket_udp_nonblock.py => socket_udp_nonblock.py} (63%) rename tests/extmod/{ussl_basic.py => ssl_basic.py} (96%) rename tests/extmod/{ussl_basic.py.exp => ssl_basic.py.exp} (100%) rename tests/extmod/{ussl_keycert.py => ssl_keycert.py} (94%) rename tests/extmod/{ussl_keycert.py.exp => ssl_keycert.py.exp} (100%) rename tests/extmod/{ussl_poll.py => ssl_poll.py} (94%) rename tests/extmod/{ussl_poll.py.exp => ssl_poll.py.exp} (100%) rename tests/extmod/{utime_res.py => time_res.py} (80%) rename tests/extmod/{utime_res.py.exp => time_res.py.exp} (100%) rename tests/extmod/{utime_time_ns.py => time_time_ns.py} (68%) rename tests/extmod/{utime_time_ns.py.exp => time_time_ns.py.exp} (100%) rename tests/extmod/{utimeq1.py => timeq1.py} (90%) rename tests/extmod/{utimeq1.py.exp => timeq1.py.exp} (100%) rename tests/extmod/{utimeq_stable.py => timeq_stable.py} (90%) rename tests/extmod/{utimeq_stable.py.exp => timeq_stable.py.exp} (100%) delete mode 100644 tests/extmod/uhashlib_md5.py delete mode 100644 tests/extmod/uhashlib_sha1.py delete mode 100644 tests/extmod/ujson_dumps_extra.py delete mode 100644 tests/extmod/ujson_dumps_float.py delete mode 100644 tests/extmod/ujson_dumps_ordereddict.py delete mode 100644 tests/extmod/ujson_load.py delete mode 100644 tests/extmod/ure_stack_overflow.py rename tests/extmod/{uzlib_decompio.py => zlib_decompio.py} (93%) rename tests/extmod/{uzlib_decompio.py.exp => zlib_decompio.py.exp} (100%) rename tests/extmod/{uzlib_decompio_gz.py => zlib_decompio_gz.py} (97%) rename tests/extmod/{uzlib_decompio_gz.py.exp => zlib_decompio_gz.py.exp} (100%) rename tests/extmod/{uzlib_decompress.py => zlib_decompress.py} (94%) rename tests/feature_check/{uio_module.py => io_module.py} (56%) rename tests/feature_check/{uio_module.py.exp => io_module.py.exp} (100%) rename tests/unix/{time.py => time_mktime_localtime.py} (96%) diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index ab06c0fb393..6022ff2bff7 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -356,19 +356,19 @@ STATIC mp_obj_t extra_coverage(void) { mp_printf(&mp_plat_print, "# repl\n"); const char *str; - size_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str); + size_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str); // expect "ame__" mp_printf(&mp_plat_print, "%.*s\n", (int)len, str); - len = mp_repl_autocomplete("i", 1, &mp_plat_print, &str); + len = mp_repl_autocomplete("im", 2, &mp_plat_print, &str); // expect "port" mp_printf(&mp_plat_print, "%.*s\n", (int)len, str); - mp_repl_autocomplete("import ", 7, &mp_plat_print, &str); - len = mp_repl_autocomplete("import ut", 9, &mp_plat_print, &str); + mp_repl_autocomplete("import ", 7, &mp_plat_print, &str); // expect the list of builtins + len = mp_repl_autocomplete("import ti", 9, &mp_plat_print, &str); // expect "me" mp_printf(&mp_plat_print, "%.*s\n", (int)len, str); - mp_repl_autocomplete("import time", 12, &mp_plat_print, &str); + mp_repl_autocomplete("import time", 11, &mp_plat_print, &str); // expect "time timeq" mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0))); - mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str); - len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str); + mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str); // expect dir(sys) + len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str); // expect "ementation" mp_printf(&mp_plat_print, "%.*s\n", (int)len, str); } diff --git a/tests/basics/array1.py b/tests/basics/array1.py index f21ad4bd75f..5c5d13a5816 100644 --- a/tests/basics/array1.py +++ b/tests/basics/array1.py @@ -1,11 +1,8 @@ try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit a = array.array('B', [1, 2, 3]) print(a, len(a)) diff --git a/tests/basics/array_add.py b/tests/basics/array_add.py index 8335eb6b82b..76ce59f761e 100644 --- a/tests/basics/array_add.py +++ b/tests/basics/array_add.py @@ -1,12 +1,9 @@ # test array + array try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit a1 = array.array('I', [1]) a2 = array.array('I', [2]) diff --git a/tests/basics/array_construct.py b/tests/basics/array_construct.py index 4985244d13b..2221de99068 100644 --- a/tests/basics/array_construct.py +++ b/tests/basics/array_construct.py @@ -1,13 +1,10 @@ # test construction of array.array from different objects try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # tuple, list print(array('b', (1, 2))) diff --git a/tests/basics/array_construct2.py b/tests/basics/array_construct2.py index d1b1e9d158c..c305b7f011d 100644 --- a/tests/basics/array_construct2.py +++ b/tests/basics/array_construct2.py @@ -1,11 +1,8 @@ try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # construct from something with unknown length (requires generators) print(array('i', (i for i in range(10)))) diff --git a/tests/basics/array_construct_endian.py b/tests/basics/array_construct_endian.py index 82a962fbe0d..990d7b1ea03 100644 --- a/tests/basics/array_construct_endian.py +++ b/tests/basics/array_construct_endian.py @@ -1,13 +1,10 @@ # test construction of array.array from different objects try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # raw copy from bytes, bytearray print(array('h', b'12')) diff --git a/tests/basics/array_intbig.py b/tests/basics/array_intbig.py index ba7f9ef985a..5702a8ae635 100644 --- a/tests/basics/array_intbig.py +++ b/tests/basics/array_intbig.py @@ -1,13 +1,10 @@ # test array types QqLl that require big-ints try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(array('L', [0, 2**32-1])) print(array('l', [-2**31, 0, 2**31-1])) diff --git a/tests/basics/array_micropython.py b/tests/basics/array_micropython.py index 44dc1d83d8e..771a7d709cb 100644 --- a/tests/basics/array_micropython.py +++ b/tests/basics/array_micropython.py @@ -1,12 +1,9 @@ # test MicroPython-specific features of array.array try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # arrays of objects a = array.array('O') diff --git a/tests/basics/async_await2.py b/tests/basics/async_await2.py index 56f77604ac1..1e3164df933 100644 --- a/tests/basics/async_await2.py +++ b/tests/basics/async_await2.py @@ -1,9 +1,6 @@ # test await expression -try: - import usys as sys -except ImportError: - import sys +import sys if sys.implementation.name == 'micropython': # uPy allows normal generators to be awaitables coroutine = lambda f: f diff --git a/tests/basics/async_for2.py b/tests/basics/async_for2.py index 4af3be4c6df..aad23a3e5ad 100644 --- a/tests/basics/async_for2.py +++ b/tests/basics/async_for2.py @@ -1,9 +1,6 @@ # test waiting within "async for" __anext__ function -try: - import usys as sys -except ImportError: - import sys +import sys if sys.implementation.name == 'micropython': # uPy allows normal generators to be awaitables coroutine = lambda f: f diff --git a/tests/basics/async_with2.py b/tests/basics/async_with2.py index 4dd1386240f..44421ae9179 100644 --- a/tests/basics/async_with2.py +++ b/tests/basics/async_with2.py @@ -1,9 +1,6 @@ # test waiting within async with enter/exit functions -try: - import usys as sys -except ImportError: - import sys +import sys if sys.implementation.name == 'micropython': # uPy allows normal generators to be awaitables coroutine = lambda f: f diff --git a/tests/basics/attrtuple1.py b/tests/basics/attrtuple1.py index 249c030bb4f..78a0fbed1b7 100644 --- a/tests/basics/attrtuple1.py +++ b/tests/basics/attrtuple1.py @@ -1,10 +1,7 @@ # test attrtuple # we can't test this type directly so we use sys.implementation object -try: - import usys as sys -except ImportError: - import sys +import sys t = sys.implementation # It can be just a normal tuple on small ports diff --git a/tests/basics/builtin_callable.py b/tests/basics/builtin_callable.py index c0a9d0c473a..3ae49f004d1 100644 --- a/tests/basics/builtin_callable.py +++ b/tests/basics/builtin_callable.py @@ -7,10 +7,7 @@ print(callable("dfsd")) # modules should not be callabe -try: - import usys as sys -except ImportError: - import sys +import sys print(callable(sys)) # builtins should be callable diff --git a/tests/basics/builtin_dir.py b/tests/basics/builtin_dir.py index 1f2b498d77f..1eecbd044b7 100644 --- a/tests/basics/builtin_dir.py +++ b/tests/basics/builtin_dir.py @@ -4,10 +4,7 @@ print('__name__' in dir()) # dir of module -try: - import usys as sys -except ImportError: - import sys +import sys print('version' in dir(sys)) # dir of type diff --git a/tests/basics/bytearray_construct_array.py b/tests/basics/bytearray_construct_array.py index 52eaa7c6efb..bde5fa08bd2 100644 --- a/tests/basics/bytearray_construct_array.py +++ b/tests/basics/bytearray_construct_array.py @@ -1,12 +1,9 @@ # test construction of bytearray from different objects try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # arrays print(bytearray(array('b', [1, 2]))) diff --git a/tests/basics/bytearray_construct_endian.py b/tests/basics/bytearray_construct_endian.py index 332b43e6861..0002f19c5f9 100644 --- a/tests/basics/bytearray_construct_endian.py +++ b/tests/basics/bytearray_construct_endian.py @@ -1,12 +1,9 @@ # test construction of bytearray from different objects try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # arrays print(bytearray(array('h', [1, 2]))) diff --git a/tests/basics/bytes_add_array.py b/tests/basics/bytes_add_array.py index c6382bed749..b17556d83cb 100644 --- a/tests/basics/bytes_add_array.py +++ b/tests/basics/bytes_add_array.py @@ -1,12 +1,9 @@ # test bytes + other try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # should be byteorder-neutral print(b"123" + array.array('h', [0x1515])) diff --git a/tests/basics/bytes_add_endian.py b/tests/basics/bytes_add_endian.py index 40b3de7d615..8cfffa7b6ac 100644 --- a/tests/basics/bytes_add_endian.py +++ b/tests/basics/bytes_add_endian.py @@ -1,11 +1,8 @@ # test bytes + other try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(b"123" + array.array('i', [1])) diff --git a/tests/basics/bytes_compare_array.py b/tests/basics/bytes_compare_array.py index 6bad50b55a1..ad378de70c5 100644 --- a/tests/basics/bytes_compare_array.py +++ b/tests/basics/bytes_compare_array.py @@ -1,11 +1,8 @@ try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(array.array('b', [1, 2]) in b'\x01\x02\x03') # CPython gives False here diff --git a/tests/basics/bytes_construct_array.py b/tests/basics/bytes_construct_array.py index 7bdd8f10df4..453eb590103 100644 --- a/tests/basics/bytes_construct_array.py +++ b/tests/basics/bytes_construct_array.py @@ -1,12 +1,9 @@ # test construction of bytes from different objects try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # arrays print(bytes(array('b', [1, 2]))) diff --git a/tests/basics/bytes_construct_endian.py b/tests/basics/bytes_construct_endian.py index 294c5f23f5c..cf1a9f408fa 100644 --- a/tests/basics/bytes_construct_endian.py +++ b/tests/basics/bytes_construct_endian.py @@ -1,13 +1,10 @@ # test construction of bytes from different objects try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # arrays print(bytes(array('h', [1, 2]))) diff --git a/tests/basics/class_ordereddict.py b/tests/basics/class_ordereddict.py index 4dd25eb6e15..03a211ddad2 100644 --- a/tests/basics/class_ordereddict.py +++ b/tests/basics/class_ordereddict.py @@ -1,13 +1,10 @@ # test using an OrderedDict as the locals to construct a class try: - from ucollections import OrderedDict + from collections import OrderedDict except ImportError: - try: - from collections import OrderedDict - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit if not hasattr(int, "__dict__"): print("SKIP") diff --git a/tests/basics/class_store_class.py b/tests/basics/class_store_class.py index 797f88f8526..8ee2f8db11b 100644 --- a/tests/basics/class_store_class.py +++ b/tests/basics/class_store_class.py @@ -5,11 +5,8 @@ try: from collections import namedtuple except ImportError: - try: - from ucollections import namedtuple - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit _DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ]) diff --git a/tests/basics/deque1.py b/tests/basics/deque1.py index 19966fcb078..8b7874e2b1d 100644 --- a/tests/basics/deque1.py +++ b/tests/basics/deque1.py @@ -1,8 +1,5 @@ try: - try: - from ucollections import deque - except ImportError: - from collections import deque + from collections import deque except ImportError: print("SKIP") raise SystemExit diff --git a/tests/basics/deque2.py b/tests/basics/deque2.py index 22d370e943b..80fcd667856 100644 --- a/tests/basics/deque2.py +++ b/tests/basics/deque2.py @@ -1,10 +1,7 @@ # Tests for deques with "check overflow" flag and other extensions # wrt to CPython. try: - try: - from ucollections import deque - except ImportError: - from collections import deque + from collections import deque except ImportError: print("SKIP") raise SystemExit diff --git a/tests/basics/dict_fixed.py b/tests/basics/dict_fixed.py index 4261a06557a..cfd3b71f574 100644 --- a/tests/basics/dict_fixed.py +++ b/tests/basics/dict_fixed.py @@ -1,48 +1,48 @@ # test that fixed dictionaries cannot be modified try: - import uerrno + import errno except ImportError: print("SKIP") raise SystemExit -# Save a copy of uerrno.errorcode, so we can check later +# Save a copy of errno.errorcode, so we can check later # that it hasn't been modified. -errorcode_copy = uerrno.errorcode.copy() +errorcode_copy = errno.errorcode.copy() try: - uerrno.errorcode.popitem() + errno.errorcode.popitem() except TypeError: print("TypeError") try: - uerrno.errorcode.pop(0) + errno.errorcode.pop(0) except TypeError: print("TypeError") try: - uerrno.errorcode.setdefault(0, 0) + errno.errorcode.setdefault(0, 0) except TypeError: print("TypeError") try: - uerrno.errorcode.update([(1, 2)]) + errno.errorcode.update([(1, 2)]) except TypeError: print("TypeError") try: - del uerrno.errorcode[1] + del errno.errorcode[1] except TypeError: print("TypeError") try: - uerrno.errorcode[1] = 'foo' + errno.errorcode[1] = 'foo' except TypeError: print("TypeError") try: - uerrno.errorcode.clear() + errno.errorcode.clear() except TypeError: print("TypeError") -assert uerrno.errorcode == errorcode_copy +assert errno.errorcode == errorcode_copy diff --git a/tests/basics/errno1.py b/tests/basics/errno1.py index d9a895a972d..0773c926fde 100644 --- a/tests/basics/errno1.py +++ b/tests/basics/errno1.py @@ -1,25 +1,25 @@ -# test errno's and uerrno module +# test errno's and errno module try: - import uerrno + import errno except ImportError: print("SKIP") raise SystemExit # check that constants exist and are integers -print(type(uerrno.EIO)) +print(type(errno.EIO)) # check that errors are rendered in a nice way -msg = str(OSError(uerrno.EIO)) +msg = str(OSError(errno.EIO)) print(msg[:7], msg[-5:]) -msg = str(OSError(uerrno.EIO, "details")) +msg = str(OSError(errno.EIO, "details")) print(msg[:7], msg[-14:]) -msg = str(OSError(uerrno.EIO, "details", "more details")) +msg = str(OSError(errno.EIO, "details", "more details")) print(msg[:1], msg[-28:]) # check that unknown errno is still rendered print(str(OSError(9999))) # this tests a failed constant lookup in errno -errno = uerrno +errno = errno print(errno.__name__) diff --git a/tests/basics/errno1.py.exp b/tests/basics/errno1.py.exp index 58605b4767a..7a9ffea8f7c 100644 --- a/tests/basics/errno1.py.exp +++ b/tests/basics/errno1.py.exp @@ -3,4 +3,4 @@ [Errno ] EIO: details ( , 'details', 'more details') 9999 -uerrno +errno diff --git a/tests/basics/int_big1.py b/tests/basics/int_big1.py index ea48372b283..de2ba9fc4f2 100644 --- a/tests/basics/int_big1.py +++ b/tests/basics/int_big1.py @@ -105,10 +105,7 @@ x = -4611686018427387904 # big # sys.maxsize is a constant mpz, so test it's compatible with dynamic ones -try: - import usys as sys -except ImportError: - import sys +import sys print(sys.maxsize + 1 - 1 == sys.maxsize) # test extraction of big int value via mp_obj_get_int_maybe diff --git a/tests/basics/io_buffered_writer.py b/tests/basics/io_buffered_writer.py index 0e943cb0a90..5c065f158a2 100644 --- a/tests/basics/io_buffered_writer.py +++ b/tests/basics/io_buffered_writer.py @@ -1,4 +1,4 @@ -import uio as io +import io try: io.BytesIO diff --git a/tests/basics/io_bytesio_cow.py b/tests/basics/io_bytesio_cow.py index 92654a0003f..2edb7136a96 100644 --- a/tests/basics/io_bytesio_cow.py +++ b/tests/basics/io_bytesio_cow.py @@ -1,10 +1,6 @@ # Make sure that write operations on io.BytesIO don't # change original object it was constructed from. -try: - import uio as io -except ImportError: - import io - +import io b = b"foobar" a = io.BytesIO(b) diff --git a/tests/basics/io_bytesio_ext.py b/tests/basics/io_bytesio_ext.py index e454b2fd9f2..4d4c60c1363 100644 --- a/tests/basics/io_bytesio_ext.py +++ b/tests/basics/io_bytesio_ext.py @@ -1,9 +1,5 @@ # Extended stream operations on io.BytesIO -try: - import uio as io -except ImportError: - import io - +import io a = io.BytesIO(b"foobar") a.seek(10) print(a.read(10)) diff --git a/tests/basics/io_bytesio_ext2.py b/tests/basics/io_bytesio_ext2.py index 8f624fd58c5..414ac90a3b0 100644 --- a/tests/basics/io_bytesio_ext2.py +++ b/tests/basics/io_bytesio_ext2.py @@ -1,8 +1,4 @@ -try: - import uio as io -except ImportError: - import io - +import io a = io.BytesIO(b"foobar") try: a.seek(-10) diff --git a/tests/basics/io_iobase.py b/tests/basics/io_iobase.py index 6f554b00f08..d3824c177f3 100644 --- a/tests/basics/io_iobase.py +++ b/tests/basics/io_iobase.py @@ -1,8 +1,4 @@ -try: - import uio as io -except: - import io - +import io try: io.IOBase except AttributeError: diff --git a/tests/basics/io_stringio1.py b/tests/basics/io_stringio1.py index 41089f22d53..7d355930f5a 100644 --- a/tests/basics/io_stringio1.py +++ b/tests/basics/io_stringio1.py @@ -1,8 +1,4 @@ -try: - import uio as io -except ImportError: - import io - +import io a = io.StringIO() print('io.StringIO' in repr(a)) print(a.getvalue()) diff --git a/tests/basics/io_stringio_base.py b/tests/basics/io_stringio_base.py index dffc879074a..0f65fb3fabc 100644 --- a/tests/basics/io_stringio_base.py +++ b/tests/basics/io_stringio_base.py @@ -1,10 +1,7 @@ # Checks that an instance type inheriting from a native base that uses # MP_TYPE_FLAG_ITER_IS_STREAM will still have a getiter. -try: - import uio as io -except ImportError: - import io +import io a = io.StringIO() a.write("hello\nworld\nmicro\npython\n") diff --git a/tests/basics/io_stringio_with.py b/tests/basics/io_stringio_with.py index c35975445df..a3aa6ec84e0 100644 --- a/tests/basics/io_stringio_with.py +++ b/tests/basics/io_stringio_with.py @@ -1,8 +1,4 @@ -try: - import uio as io -except ImportError: - import io - +import io # test __enter__/__exit__ with io.StringIO() as b: b.write("foo") diff --git a/tests/basics/io_write_ext.py b/tests/basics/io_write_ext.py index 5a6eaa35cf0..695abccef44 100644 --- a/tests/basics/io_write_ext.py +++ b/tests/basics/io_write_ext.py @@ -1,14 +1,14 @@ # This tests extended (MicroPython-specific) form of write: # write(buf, len) and write(buf, offset, len) -import uio +import io try: - uio.BytesIO + io.BytesIO except AttributeError: print('SKIP') raise SystemExit -buf = uio.BytesIO() +buf = io.BytesIO() buf.write(b"foo", 2) print(buf.getvalue()) diff --git a/tests/basics/memoryview1.py b/tests/basics/memoryview1.py index 4c20c91f494..1ebfbc53b92 100644 --- a/tests/basics/memoryview1.py +++ b/tests/basics/memoryview1.py @@ -5,13 +5,10 @@ print("SKIP") raise SystemExit try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # test reading from bytes b = b'1234' diff --git a/tests/basics/memoryview2.py b/tests/basics/memoryview2.py index eacc227c283..fa5514e0727 100644 --- a/tests/basics/memoryview2.py +++ b/tests/basics/memoryview2.py @@ -5,13 +5,10 @@ print("SKIP") raise SystemExit try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(list(memoryview(b'\x7f\x80\x81\xff'))) print(list(memoryview(array('b', [0x7f, -0x80])))) diff --git a/tests/basics/memoryview_intbig.py b/tests/basics/memoryview_intbig.py index 4800a70cc27..72951d6eaa8 100644 --- a/tests/basics/memoryview_intbig.py +++ b/tests/basics/memoryview_intbig.py @@ -5,13 +5,10 @@ print("SKIP") raise SystemExit try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(list(memoryview(array('i', [0x7f000000, -0x80000000])))) print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff])))) diff --git a/tests/basics/memoryview_itemsize.py b/tests/basics/memoryview_itemsize.py index 64a8822b8b2..5428a41785f 100644 --- a/tests/basics/memoryview_itemsize.py +++ b/tests/basics/memoryview_itemsize.py @@ -4,13 +4,10 @@ print("SKIP") raise SystemExit try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit for code in ['b', 'h', 'i', 'q', 'f', 'd']: print(memoryview(array(code)).itemsize) diff --git a/tests/basics/memoryview_slice_assign.py b/tests/basics/memoryview_slice_assign.py index 74f6fae6f78..94f8073f0a1 100644 --- a/tests/basics/memoryview_slice_assign.py +++ b/tests/basics/memoryview_slice_assign.py @@ -7,13 +7,10 @@ raise SystemExit try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # test slice assignment between memoryviews b1 = bytearray(b'1234') diff --git a/tests/basics/module2.py b/tests/basics/module2.py index 5923a27e08d..a135601579c 100644 --- a/tests/basics/module2.py +++ b/tests/basics/module2.py @@ -1,6 +1,6 @@ # uPy behaviour only: builtin modules are read-only -import usys +import sys try: - usys.x = 1 + sys.x = 1 except AttributeError: print("AttributeError") diff --git a/tests/basics/namedtuple1.py b/tests/basics/namedtuple1.py index e8247e4d6e1..362c60583ec 100644 --- a/tests/basics/namedtuple1.py +++ b/tests/basics/namedtuple1.py @@ -1,8 +1,5 @@ try: - try: - from ucollections import namedtuple - except ImportError: - from collections import namedtuple + from collections import namedtuple except ImportError: print("SKIP") raise SystemExit diff --git a/tests/basics/namedtuple_asdict.py b/tests/basics/namedtuple_asdict.py index 34c4e6f7131..e85281bb73e 100644 --- a/tests/basics/namedtuple_asdict.py +++ b/tests/basics/namedtuple_asdict.py @@ -1,8 +1,5 @@ try: - try: - from ucollections import namedtuple - except ImportError: - from collections import namedtuple + from collections import namedtuple except ImportError: print("SKIP") raise SystemExit diff --git a/tests/basics/ordereddict1.py b/tests/basics/ordereddict1.py index 270deab3846..a6f305ff78b 100644 --- a/tests/basics/ordereddict1.py +++ b/tests/basics/ordereddict1.py @@ -1,11 +1,8 @@ try: from collections import OrderedDict except ImportError: - try: - from ucollections import OrderedDict - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit d = OrderedDict([(10, 20), ("b", 100), (1, 2)]) print(len(d)) diff --git a/tests/basics/ordereddict_eq.py b/tests/basics/ordereddict_eq.py index c69daf8802c..e103c867e23 100644 --- a/tests/basics/ordereddict_eq.py +++ b/tests/basics/ordereddict_eq.py @@ -1,11 +1,8 @@ try: from collections import OrderedDict except ImportError: - try: - from ucollections import OrderedDict - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit x = OrderedDict() y = OrderedDict() diff --git a/tests/basics/python34.py b/tests/basics/python34.py index 36e25e20dd5..922234d22db 100644 --- a/tests/basics/python34.py +++ b/tests/basics/python34.py @@ -29,9 +29,9 @@ def test_syntax(code): # from basics/sys1.py # uPy prints version 3.4 -import usys -print(usys.version[:3]) -print(usys.version_info[0], usys.version_info[1]) +import sys +print(sys.version[:3]) +print(sys.version_info[0], sys.version_info[1]) # from basics/exception1.py # in 3.7 no comma is printed if there is only 1 arg (in 3.4-3.6 one is printed) diff --git a/tests/basics/string_compare.py b/tests/basics/string_compare.py index f34879df25b..6515809b364 100644 --- a/tests/basics/string_compare.py +++ b/tests/basics/string_compare.py @@ -51,10 +51,7 @@ # this tests an internal string that doesn't have a hash with a string # that does have a hash, but the lengths of the two strings are different -try: - import usys as sys -except ImportError: - import sys +import sys print(sys.version == 'a long string that has a hash') # this special string would have a hash of 0 but is incremented to 1 diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py index c4960d2f801..a18655517bb 100644 --- a/tests/basics/struct1.py +++ b/tests/basics/struct1.py @@ -1,11 +1,8 @@ try: - import ustruct as struct -except: - try: - import struct - except ImportError: - print("SKIP") - raise SystemExit + import struct +except ImportError: + print("SKIP") + raise SystemExit print(struct.calcsize(" 0 except ImportError: pass diff --git a/tests/basics/sys_path.py b/tests/basics/sys_path.py index 6456e240197..576bd66c94d 100644 --- a/tests/basics/sys_path.py +++ b/tests/basics/sys_path.py @@ -1,10 +1,6 @@ # test sys.path -try: - import usys as sys -except ImportError: - import sys - +import sys # check that this script was executed from a file of the same name if "__file__" not in globals() or "sys_path.py" not in __file__: print("SKIP") diff --git a/tests/basics/sys_tracebacklimit.py b/tests/basics/sys_tracebacklimit.py index 1ee638967f1..3ae372b8d52 100644 --- a/tests/basics/sys_tracebacklimit.py +++ b/tests/basics/sys_tracebacklimit.py @@ -1,12 +1,8 @@ # test sys.tracebacklimit try: - try: - import usys as sys - import uio as io - except ImportError: - import sys - import io + import sys + import io except ImportError: print("SKIP") raise SystemExit diff --git a/tests/basics/sys_tracebacklimit.py.exp b/tests/basics/sys_tracebacklimit.py.exp index 3647280584d..39c54523a05 100644 --- a/tests/basics/sys_tracebacklimit.py.exp +++ b/tests/basics/sys_tracebacklimit.py.exp @@ -1,35 +1,35 @@ Traceback (most recent call last): - File , line 62, in ftop - File , line 57, in f3 - File , line 53, in f2 - File , line 49, in f1 - File , line 45, in f0 + File , line 58, in ftop + File , line 53, in f3 + File , line 49, in f2 + File , line 45, in f1 + File , line 41, in f0 ValueError: value limit 4 Traceback (most recent call last): - File , line 62, in ftop - File , line 57, in f3 - File , line 53, in f2 - File , line 49, in f1 + File , line 58, in ftop + File , line 53, in f3 + File , line 49, in f2 + File , line 45, in f1 ValueError: value limit 3 Traceback (most recent call last): - File , line 62, in ftop - File , line 57, in f3 - File , line 53, in f2 + File , line 58, in ftop + File , line 53, in f3 + File , line 49, in f2 ValueError: value limit 2 Traceback (most recent call last): - File , line 62, in ftop - File , line 57, in f3 + File , line 58, in ftop + File , line 53, in f3 ValueError: value limit 1 Traceback (most recent call last): - File , line 62, in ftop + File , line 58, in ftop ValueError: value limit 0 diff --git a/tests/cmdline/repl_micropyinspect b/tests/cmdline/repl_micropyinspect index 0710f1a75be..8dfa8810ea4 100644 --- a/tests/cmdline/repl_micropyinspect +++ b/tests/cmdline/repl_micropyinspect @@ -1,3 +1,3 @@ -import uos +import os -uos.putenv('MICROPYINSPECT', '1') +os.putenv('MICROPYINSPECT', '1') diff --git a/tests/cmdline/repl_sys_ps1_ps2.py b/tests/cmdline/repl_sys_ps1_ps2.py index 4f96057c49b..cfefe804bf2 100644 --- a/tests/cmdline/repl_sys_ps1_ps2.py +++ b/tests/cmdline/repl_sys_ps1_ps2.py @@ -1,6 +1,6 @@ # test changing ps1/ps2 -import usys -usys.ps1 = "PS1" -usys.ps2 = "PS2" +import sys +sys.ps1 = "PS1" +sys.ps2 = "PS2" (1 + 2) diff --git a/tests/cmdline/repl_sys_ps1_ps2.py.exp b/tests/cmdline/repl_sys_ps1_ps2.py.exp index e4a802d34d7..9e82db5e313 100644 --- a/tests/cmdline/repl_sys_ps1_ps2.py.exp +++ b/tests/cmdline/repl_sys_ps1_ps2.py.exp @@ -1,9 +1,9 @@ MicroPython \.\+ version Use \.\+ >>> # test changing ps1/ps2 ->>> import usys ->>> usys.ps1 = "PS1" -PS1usys.ps2 = "PS2" +>>> import sys +>>> sys.ps1 = "PS1" +PS1sys.ps2 = "PS2" PS1(1 + PS22) 3 diff --git a/tests/esp32/partition_ota.py b/tests/esp32/partition_ota.py index 212fcf03385..65e2742ebb2 100644 --- a/tests/esp32/partition_ota.py +++ b/tests/esp32/partition_ota.py @@ -22,10 +22,10 @@ def log(*args): # replace boot.py with the test code that will run on each reboot -import uos +import os try: - uos.rename("boot.py", "boot-orig.py") + os.rename("boot.py", "boot-orig.py") except: pass with open("boot.py", "w") as f: @@ -74,10 +74,10 @@ def log(*args): elif STEP == 4: log("Confirming boot ok and DONE!") Partition.mark_app_valid_cancel_rollback() - import uos - uos.remove("step.py") - uos.remove("boot.py") - uos.rename("boot-orig.py", "boot.py") + import os + os.remove("step.py") + os.remove("boot.py") + os.rename("boot-orig.py", "boot.py") print("\\nSUCCESS!\\n\\x04\\x04") """ diff --git a/tests/esp32/resolve_on_connect.py b/tests/esp32/resolve_on_connect.py index 068757ab2ab..e604ce9ca09 100644 --- a/tests/esp32/resolve_on_connect.py +++ b/tests/esp32/resolve_on_connect.py @@ -5,10 +5,7 @@ print("SKIP") raise SystemExit -try: - import usocket as socket, sys -except: - import socket, sys +import socket, sys def test_bind_resolves_0_0_0_0(): diff --git a/tests/extmod/ubinascii_a2b_base64.py b/tests/extmod/binascii_a2b_base64.py similarity index 92% rename from tests/extmod/ubinascii_a2b_base64.py rename to tests/extmod/binascii_a2b_base64.py index 2630965e6a0..fd1ff75e1fc 100644 --- a/tests/extmod/ubinascii_a2b_base64.py +++ b/tests/extmod/binascii_a2b_base64.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ubinascii_b2a_base64.py b/tests/extmod/binascii_b2a_base64.py similarity index 88% rename from tests/extmod/ubinascii_b2a_base64.py rename to tests/extmod/binascii_b2a_base64.py index 3f92488969e..306af940048 100644 --- a/tests/extmod/ubinascii_b2a_base64.py +++ b/tests/extmod/binascii_b2a_base64.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ubinascii_crc32.py b/tests/extmod/binascii_crc32.py similarity index 87% rename from tests/extmod/ubinascii_crc32.py rename to tests/extmod/binascii_crc32.py index 8f5f4d9ba5e..0e4a5b58f33 100644 --- a/tests/extmod/ubinascii_crc32.py +++ b/tests/extmod/binascii_crc32.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ubinascii_hexlify.py b/tests/extmod/binascii_hexlify.py similarity index 80% rename from tests/extmod/ubinascii_hexlify.py rename to tests/extmod/binascii_hexlify.py index 3c266fb6cc0..d06029aabaf 100644 --- a/tests/extmod/ubinascii_hexlify.py +++ b/tests/extmod/binascii_hexlify.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ubinascii_unhexlify.py b/tests/extmod/binascii_unhexlify.py similarity index 81% rename from tests/extmod/ubinascii_unhexlify.py rename to tests/extmod/binascii_unhexlify.py index 2c3598ab98e..bb663bc5b0c 100644 --- a/tests/extmod/ubinascii_unhexlify.py +++ b/tests/extmod/binascii_unhexlify.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/btree1.py b/tests/extmod/btree1.py index 876bce4f875..d142a370f4d 100644 --- a/tests/extmod/btree1.py +++ b/tests/extmod/btree1.py @@ -1,13 +1,13 @@ try: import btree - import uio - import uerrno + import io + import errno except ImportError: print("SKIP") raise SystemExit # f = open("_test.db", "w+b") -f = uio.BytesIO() +f = io.BytesIO() db = btree.open(f, pagesize=512) mv = memoryview(b"bar1foo1") @@ -68,7 +68,7 @@ try: db.seq(b"foo1") except OSError as e: - print(e.errno == uerrno.EINVAL) + print(e.errno == errno.EINVAL) print(list(db.keys())) print(list(db.values())) diff --git a/tests/extmod/btree_error.py b/tests/extmod/btree_error.py index b64769e8840..2dd0d137a00 100644 --- a/tests/extmod/btree_error.py +++ b/tests/extmod/btree_error.py @@ -1,15 +1,15 @@ # Test that errno's propagate correctly through btree module. try: - import btree, uio, uerrno + import btree, io, errno - uio.IOBase + io.IOBase except (ImportError, AttributeError): print("SKIP") raise SystemExit -class Device(uio.IOBase): +class Device(io.IOBase): def __init__(self, read_ret=0, ioctl_ret=0): self.read_ret = read_ret self.ioctl_ret = ioctl_ret @@ -25,18 +25,24 @@ def ioctl(self, cmd, arg): # Invalid pagesize; errno comes from btree library try: + import btree, io, errno + db = btree.open(Device(), pagesize=511) except OSError as er: - print("OSError", er.errno == uerrno.EINVAL) + print("OSError", er.errno == errno.EINVAL) # Valid pagesize, device returns error on read; errno comes from Device.readinto try: + import btree, io, errno + db = btree.open(Device(-1000), pagesize=512) except OSError as er: print(repr(er)) # Valid pagesize, device returns error on seek; errno comes from Device.ioctl try: + import btree, io, errno + db = btree.open(Device(0, -1001), pagesize=512) except OSError as er: print(repr(er)) diff --git a/tests/extmod/btree_gc.py b/tests/extmod/btree_gc.py index 1845aa06409..c5274eb4896 100644 --- a/tests/extmod/btree_gc.py +++ b/tests/extmod/btree_gc.py @@ -1,7 +1,7 @@ # Test btree interaction with the garbage collector. try: - import btree, uio, gc + import btree, io, gc except ImportError: print("SKIP") raise SystemExit @@ -9,7 +9,7 @@ N = 80 # Create a BytesIO but don't keep a reference to it. -db = btree.open(uio.BytesIO(), pagesize=512) +db = btree.open(io.BytesIO(), pagesize=512) # Overwrite lots of the Python stack to make sure no reference to the BytesIO remains. x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] diff --git a/tests/extmod/ucryptolib_aes128_cbc.py b/tests/extmod/cryptolib_aes128_cbc.py similarity index 90% rename from tests/extmod/ucryptolib_aes128_cbc.py rename to tests/extmod/cryptolib_aes128_cbc.py index d861d2c6bf4..ef6d4536856 100644 --- a/tests/extmod/ucryptolib_aes128_cbc.py +++ b/tests/extmod/cryptolib_aes128_cbc.py @@ -4,7 +4,7 @@ aes = AES.new except ImportError: try: - from ucryptolib import aes + from cryptolib import aes except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ucryptolib_aes128_cbc.py.exp b/tests/extmod/cryptolib_aes128_cbc.py.exp similarity index 100% rename from tests/extmod/ucryptolib_aes128_cbc.py.exp rename to tests/extmod/cryptolib_aes128_cbc.py.exp diff --git a/tests/extmod/ucryptolib_aes128_ctr.py b/tests/extmod/cryptolib_aes128_ctr.py similarity index 94% rename from tests/extmod/ucryptolib_aes128_ctr.py rename to tests/extmod/cryptolib_aes128_ctr.py index 538d9606e9e..b5066fb7b48 100644 --- a/tests/extmod/ucryptolib_aes128_ctr.py +++ b/tests/extmod/cryptolib_aes128_ctr.py @@ -1,5 +1,5 @@ try: - from ucryptolib import aes + from cryptolib import aes except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ucryptolib_aes128_ctr.py.exp b/tests/extmod/cryptolib_aes128_ctr.py.exp similarity index 100% rename from tests/extmod/ucryptolib_aes128_ctr.py.exp rename to tests/extmod/cryptolib_aes128_ctr.py.exp diff --git a/tests/extmod/ucryptolib_aes128_ecb.py b/tests/extmod/cryptolib_aes128_ecb.py similarity index 89% rename from tests/extmod/ucryptolib_aes128_ecb.py rename to tests/extmod/cryptolib_aes128_ecb.py index 5c0e1799868..d1e77d326d0 100644 --- a/tests/extmod/ucryptolib_aes128_ecb.py +++ b/tests/extmod/cryptolib_aes128_ecb.py @@ -4,7 +4,7 @@ aes = AES.new except ImportError: try: - from ucryptolib import aes + from cryptolib import aes except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ucryptolib_aes128_ecb.py.exp b/tests/extmod/cryptolib_aes128_ecb.py.exp similarity index 100% rename from tests/extmod/ucryptolib_aes128_ecb.py.exp rename to tests/extmod/cryptolib_aes128_ecb.py.exp diff --git a/tests/extmod/ucryptolib_aes128_ecb_enc.py b/tests/extmod/cryptolib_aes128_ecb_enc.py similarity index 91% rename from tests/extmod/ucryptolib_aes128_ecb_enc.py rename to tests/extmod/cryptolib_aes128_ecb_enc.py index 1d4484b0bc1..1bc973e22d6 100644 --- a/tests/extmod/ucryptolib_aes128_ecb_enc.py +++ b/tests/extmod/cryptolib_aes128_ecb_enc.py @@ -7,7 +7,7 @@ aes = AES.new except ImportError: try: - from ucryptolib import aes + from cryptolib import aes except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ucryptolib_aes128_ecb_enc.py.exp b/tests/extmod/cryptolib_aes128_ecb_enc.py.exp similarity index 100% rename from tests/extmod/ucryptolib_aes128_ecb_enc.py.exp rename to tests/extmod/cryptolib_aes128_ecb_enc.py.exp diff --git a/tests/extmod/ucryptolib_aes128_ecb_inpl.py b/tests/extmod/cryptolib_aes128_ecb_inpl.py similarity index 90% rename from tests/extmod/ucryptolib_aes128_ecb_inpl.py rename to tests/extmod/cryptolib_aes128_ecb_inpl.py index 88ccb02daf2..826f95ced87 100644 --- a/tests/extmod/ucryptolib_aes128_ecb_inpl.py +++ b/tests/extmod/cryptolib_aes128_ecb_inpl.py @@ -1,6 +1,6 @@ # Inplace operations (input and output buffer is the same) try: - from ucryptolib import aes + from cryptolib import aes except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ucryptolib_aes128_ecb_inpl.py.exp b/tests/extmod/cryptolib_aes128_ecb_inpl.py.exp similarity index 100% rename from tests/extmod/ucryptolib_aes128_ecb_inpl.py.exp rename to tests/extmod/cryptolib_aes128_ecb_inpl.py.exp diff --git a/tests/extmod/ucryptolib_aes128_ecb_into.py b/tests/extmod/cryptolib_aes128_ecb_into.py similarity index 90% rename from tests/extmod/ucryptolib_aes128_ecb_into.py rename to tests/extmod/cryptolib_aes128_ecb_into.py index ff832d7ef3b..f90dfcf2727 100644 --- a/tests/extmod/ucryptolib_aes128_ecb_into.py +++ b/tests/extmod/cryptolib_aes128_ecb_into.py @@ -1,6 +1,6 @@ # Operations with pre-allocated output buffer try: - from ucryptolib import aes + from cryptolib import aes except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ucryptolib_aes128_ecb_into.py.exp b/tests/extmod/cryptolib_aes128_ecb_into.py.exp similarity index 100% rename from tests/extmod/ucryptolib_aes128_ecb_into.py.exp rename to tests/extmod/cryptolib_aes128_ecb_into.py.exp diff --git a/tests/extmod/ucryptolib_aes256_cbc.py b/tests/extmod/cryptolib_aes256_cbc.py similarity index 90% rename from tests/extmod/ucryptolib_aes256_cbc.py rename to tests/extmod/cryptolib_aes256_cbc.py index c01846f199d..91a9cd7609a 100644 --- a/tests/extmod/ucryptolib_aes256_cbc.py +++ b/tests/extmod/cryptolib_aes256_cbc.py @@ -4,7 +4,7 @@ aes = AES.new except ImportError: try: - from ucryptolib import aes + from cryptolib import aes except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ucryptolib_aes256_cbc.py.exp b/tests/extmod/cryptolib_aes256_cbc.py.exp similarity index 100% rename from tests/extmod/ucryptolib_aes256_cbc.py.exp rename to tests/extmod/cryptolib_aes256_cbc.py.exp diff --git a/tests/extmod/ucryptolib_aes256_ecb.py b/tests/extmod/cryptolib_aes256_ecb.py similarity index 89% rename from tests/extmod/ucryptolib_aes256_ecb.py rename to tests/extmod/cryptolib_aes256_ecb.py index 0760063c14c..ed040bc15ba 100644 --- a/tests/extmod/ucryptolib_aes256_ecb.py +++ b/tests/extmod/cryptolib_aes256_ecb.py @@ -4,7 +4,7 @@ aes = AES.new except ImportError: try: - from ucryptolib import aes + from cryptolib import aes except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ucryptolib_aes256_ecb.py.exp b/tests/extmod/cryptolib_aes256_ecb.py.exp similarity index 100% rename from tests/extmod/ucryptolib_aes256_ecb.py.exp rename to tests/extmod/cryptolib_aes256_ecb.py.exp diff --git a/tests/extmod/framebuf16.py b/tests/extmod/framebuf16.py index cd7f5ec0158..9f373c331e5 100644 --- a/tests/extmod/framebuf16.py +++ b/tests/extmod/framebuf16.py @@ -1,11 +1,11 @@ try: - import framebuf, usys + import framebuf, sys except ImportError: print("SKIP") raise SystemExit # This test and its .exp file is based on a little-endian architecture. -if usys.byteorder != "little": +if sys.byteorder != "little": print("SKIP") raise SystemExit diff --git a/tests/extmod/framebuf_palette.py b/tests/extmod/framebuf_palette.py index f5b15fda739..ad1af2cf4c4 100644 --- a/tests/extmod/framebuf_palette.py +++ b/tests/extmod/framebuf_palette.py @@ -1,6 +1,6 @@ # Test blit between different color spaces try: - import framebuf, usys + import framebuf, sys except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/framebuf_subclass.py b/tests/extmod/framebuf_subclass.py index 4cd9ea4eb5f..162839e8bf6 100644 --- a/tests/extmod/framebuf_subclass.py +++ b/tests/extmod/framebuf_subclass.py @@ -1,13 +1,13 @@ # test subclassing framebuf.FrameBuffer try: - import framebuf, usys + import framebuf, sys except ImportError: print("SKIP") raise SystemExit # This test and its .exp file is based on a little-endian architecture. -if usys.byteorder != "little": +if sys.byteorder != "little": print("SKIP") raise SystemExit diff --git a/tests/extmod/uhashlib_final.py b/tests/extmod/hashlib_final.py similarity index 92% rename from tests/extmod/uhashlib_final.py rename to tests/extmod/hashlib_final.py index f562cc17807..c8fdac92346 100644 --- a/tests/extmod/uhashlib_final.py +++ b/tests/extmod/hashlib_final.py @@ -1,12 +1,12 @@ try: - import uhashlib + import hashlib except ImportError: print("SKIP") raise SystemExit for algo_name in ("md5", "sha1", "sha256"): - algo = getattr(uhashlib, algo_name, None) + algo = getattr(hashlib, algo_name, None) if not algo: continue diff --git a/tests/extmod/uhashlib_final.py.exp b/tests/extmod/hashlib_final.py.exp similarity index 100% rename from tests/extmod/uhashlib_final.py.exp rename to tests/extmod/hashlib_final.py.exp diff --git a/tests/extmod/hashlib_md5.py b/tests/extmod/hashlib_md5.py new file mode 100644 index 00000000000..5f925fc97d0 --- /dev/null +++ b/tests/extmod/hashlib_md5.py @@ -0,0 +1,18 @@ +try: + import hashlib +except ImportError: + # This is neither uPy, nor cPy, so must be uPy with + # hashlib module disabled. + print("SKIP") + raise SystemExit + +try: + hashlib.md5 +except AttributeError: + # MD5 is only available on some ports + print("SKIP") + raise SystemExit + +md5 = hashlib.md5(b"hello") +md5.update(b"world") +print(md5.digest()) diff --git a/tests/extmod/hashlib_sha1.py b/tests/extmod/hashlib_sha1.py new file mode 100644 index 00000000000..af23033a591 --- /dev/null +++ b/tests/extmod/hashlib_sha1.py @@ -0,0 +1,18 @@ +try: + import hashlib +except ImportError: + # This is neither uPy, nor cPy, so must be uPy with + # hashlib module disabled. + print("SKIP") + raise SystemExit + +try: + hashlib.sha1 +except AttributeError: + # SHA1 is only available on some ports + print("SKIP") + raise SystemExit + +sha1 = hashlib.sha1(b"hello") +sha1.update(b"world") +print(sha1.digest()) diff --git a/tests/extmod/uhashlib_sha256.py b/tests/extmod/hashlib_sha256.py similarity index 72% rename from tests/extmod/uhashlib_sha256.py rename to tests/extmod/hashlib_sha256.py index 2e6df7df132..f0d07e1482c 100644 --- a/tests/extmod/uhashlib_sha256.py +++ b/tests/extmod/hashlib_sha256.py @@ -1,13 +1,10 @@ try: - import uhashlib as hashlib + import hashlib except ImportError: - try: - import hashlib - except ImportError: - # This is neither uPy, nor cPy, so must be uPy with - # uhashlib module disabled. - print("SKIP") - raise SystemExit + # This is neither uPy, nor cPy, so must be uPy with + # hashlib module disabled. + print("SKIP") + raise SystemExit h = hashlib.sha256() diff --git a/tests/extmod/uheapq1.py b/tests/extmod/heapq1.py similarity index 78% rename from tests/extmod/uheapq1.py rename to tests/extmod/heapq1.py index a470bb6f71b..efe208dac3e 100644 --- a/tests/extmod/uheapq1.py +++ b/tests/extmod/heapq1.py @@ -1,11 +1,8 @@ try: - import uheapq as heapq -except: - try: - import heapq - except ImportError: - print("SKIP") - raise SystemExit + import heapq +except ImportError: + print("SKIP") + raise SystemExit try: heapq.heappop([]) diff --git a/tests/extmod/ujson_dump.py b/tests/extmod/json_dump.py similarity index 69% rename from tests/extmod/ujson_dump.py rename to tests/extmod/json_dump.py index feda8a47dda..897d33cc812 100644 --- a/tests/extmod/ujson_dump.py +++ b/tests/extmod/json_dump.py @@ -1,13 +1,9 @@ try: - from uio import StringIO - import ujson as json -except: - try: - from io import StringIO - import json - except ImportError: - print("SKIP") - raise SystemExit + from io import StringIO + import json +except ImportError: + print("SKIP") + raise SystemExit s = StringIO() json.dump(False, s) diff --git a/tests/extmod/ujson_dump_iobase.py b/tests/extmod/json_dump_iobase.py similarity index 71% rename from tests/extmod/ujson_dump_iobase.py rename to tests/extmod/json_dump_iobase.py index 7ecf23afb65..94d317b8796 100644 --- a/tests/extmod/ujson_dump_iobase.py +++ b/tests/extmod/json_dump_iobase.py @@ -1,14 +1,10 @@ -# test ujson.dump in combination with uio.IOBase +# test json.dump in combination with io.IOBase try: - import uio as io - import ujson as json + import io, json except ImportError: - try: - import io, json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit if not hasattr(io, "IOBase"): print("SKIP") diff --git a/tests/extmod/ujson_dump_separators.py b/tests/extmod/json_dump_separators.py similarity index 86% rename from tests/extmod/ujson_dump_separators.py rename to tests/extmod/json_dump_separators.py index e19b99a26d7..4f8e56dceb5 100644 --- a/tests/extmod/ujson_dump_separators.py +++ b/tests/extmod/json_dump_separators.py @@ -1,13 +1,9 @@ try: - from uio import StringIO - import ujson as json -except: - try: - from io import StringIO - import json - except ImportError: - print("SKIP") - raise SystemExit + from io import StringIO + import json +except ImportError: + print("SKIP") + raise SystemExit for sep in [ None, diff --git a/tests/extmod/ujson_dumps.py b/tests/extmod/json_dumps.py similarity index 83% rename from tests/extmod/ujson_dumps.py rename to tests/extmod/json_dumps.py index 251b2687557..16f144e44fc 100644 --- a/tests/extmod/ujson_dumps.py +++ b/tests/extmod/json_dumps.py @@ -1,11 +1,8 @@ try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(json.dumps(False)) print(json.dumps(True)) diff --git a/tests/extmod/json_dumps_extra.py b/tests/extmod/json_dumps_extra.py new file mode 100644 index 00000000000..9074416a99d --- /dev/null +++ b/tests/extmod/json_dumps_extra.py @@ -0,0 +1,9 @@ +# test uPy json behaviour that's not valid in CPy + +try: + import json +except ImportError: + print("SKIP") + raise SystemExit + +print(json.dumps(b"1234")) diff --git a/tests/extmod/ujson_dumps_extra.py.exp b/tests/extmod/json_dumps_extra.py.exp similarity index 100% rename from tests/extmod/ujson_dumps_extra.py.exp rename to tests/extmod/json_dumps_extra.py.exp diff --git a/tests/extmod/json_dumps_float.py b/tests/extmod/json_dumps_float.py new file mode 100644 index 00000000000..25fbc5c5126 --- /dev/null +++ b/tests/extmod/json_dumps_float.py @@ -0,0 +1,8 @@ +try: + import json +except ImportError: + print("SKIP") + raise SystemExit + +print(json.dumps(1.2)) +print(json.dumps({1.5: "hi"})) diff --git a/tests/extmod/json_dumps_ordereddict.py b/tests/extmod/json_dumps_ordereddict.py new file mode 100644 index 00000000000..e1fa2a659cb --- /dev/null +++ b/tests/extmod/json_dumps_ordereddict.py @@ -0,0 +1,8 @@ +try: + import json + from collections import OrderedDict +except ImportError: + print("SKIP") + raise SystemExit + +print(json.dumps(OrderedDict(((1, 2), (3, 4))))) diff --git a/tests/extmod/ujson_dumps_separators.py b/tests/extmod/json_dumps_separators.py similarity index 93% rename from tests/extmod/ujson_dumps_separators.py rename to tests/extmod/json_dumps_separators.py index efb541fe8bf..a3a9ec308f0 100644 --- a/tests/extmod/ujson_dumps_separators.py +++ b/tests/extmod/json_dumps_separators.py @@ -1,11 +1,8 @@ try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit for sep in [ None, diff --git a/tests/extmod/json_load.py b/tests/extmod/json_load.py new file mode 100644 index 00000000000..b2c7733282a --- /dev/null +++ b/tests/extmod/json_load.py @@ -0,0 +1,11 @@ +try: + from io import StringIO + import json +except ImportError: + print("SKIP") + raise SystemExit + +print(json.load(StringIO("null"))) +print(json.load(StringIO('"abc\\u0064e"'))) +print(json.load(StringIO("[false, true, 1, -2]"))) +print(json.load(StringIO('{"a":true}'))) diff --git a/tests/extmod/ujson_loads.py b/tests/extmod/json_loads.py similarity index 92% rename from tests/extmod/ujson_loads.py rename to tests/extmod/json_loads.py index 2de9cdcbc1a..f9073c121e2 100644 --- a/tests/extmod/ujson_loads.py +++ b/tests/extmod/json_loads.py @@ -1,11 +1,8 @@ try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def my_print(o): diff --git a/tests/extmod/ujson_loads_bytes.py b/tests/extmod/json_loads_bytes.py similarity index 56% rename from tests/extmod/ujson_loads_bytes.py rename to tests/extmod/json_loads_bytes.py index 3ee87bbcd58..45cd0a35c5a 100644 --- a/tests/extmod/ujson_loads_bytes.py +++ b/tests/extmod/json_loads_bytes.py @@ -1,13 +1,10 @@ # test loading from bytes and bytearray (introduced in Python 3.6) try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(json.loads(b"[1,2]")) print(json.loads(bytearray(b"[null]"))) diff --git a/tests/extmod/ujson_loads_bytes.py.exp b/tests/extmod/json_loads_bytes.py.exp similarity index 100% rename from tests/extmod/ujson_loads_bytes.py.exp rename to tests/extmod/json_loads_bytes.py.exp diff --git a/tests/extmod/ujson_loads_float.py b/tests/extmod/json_loads_float.py similarity index 65% rename from tests/extmod/ujson_loads_float.py rename to tests/extmod/json_loads_float.py index 842718f37de..2a8402dc6a2 100644 --- a/tests/extmod/ujson_loads_float.py +++ b/tests/extmod/json_loads_float.py @@ -1,11 +1,8 @@ try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def my_print(o): diff --git a/tests/extmod/machine1.py b/tests/extmod/machine1.py index 0c7f8122f4a..90e6d17174f 100644 --- a/tests/extmod/machine1.py +++ b/tests/extmod/machine1.py @@ -1,10 +1,8 @@ # test machine module try: - try: - import umachine as machine - except ImportError: - import machine + import machine + machine.mem8 except: print("SKIP") diff --git a/tests/extmod/machine_pinbase.py b/tests/extmod/machine_pinbase.py index 8bddd4bb706..4c467c2d26e 100644 --- a/tests/extmod/machine_pinbase.py +++ b/tests/extmod/machine_pinbase.py @@ -1,8 +1,6 @@ try: - try: - import umachine as machine - except ImportError: - import machine + import machine + machine.PinBase except: print("SKIP") diff --git a/tests/extmod/machine_pulse.py b/tests/extmod/machine_pulse.py index 65d15fb3513..c793134e197 100644 --- a/tests/extmod/machine_pulse.py +++ b/tests/extmod/machine_pulse.py @@ -1,8 +1,6 @@ try: - try: - import umachine as machine - except ImportError: - import machine + import machine + machine.PinBase machine.time_pulse_us except: diff --git a/tests/extmod/machine_signal.py b/tests/extmod/machine_signal.py index 1ffdb564360..2f6332748d5 100644 --- a/tests/extmod/machine_signal.py +++ b/tests/extmod/machine_signal.py @@ -1,10 +1,8 @@ # test machine.Signal class try: - try: - import umachine as machine - except ImportError: - import machine + import machine + machine.PinBase machine.Signal except: diff --git a/tests/extmod/machine_timer.py b/tests/extmod/machine_timer.py index c9a47c40258..1be01d184d4 100644 --- a/tests/extmod/machine_timer.py +++ b/tests/extmod/machine_timer.py @@ -1,7 +1,7 @@ # test machine.Timer try: - import utime, umachine as machine + import time, machine as machine machine.Timer except: @@ -29,10 +29,10 @@ # create one-shot timer with callback and wait for it to print (should be just once) t = machine.Timer(period=1, mode=machine.Timer.ONE_SHOT, callback=lambda t: print("one-shot")) -utime.sleep_ms(5) +time.sleep_ms(5) t.deinit() # create periodic timer with callback and wait for it to print t = machine.Timer(period=4, mode=machine.Timer.PERIODIC, callback=lambda t: print("periodic")) -utime.sleep_ms(14) +time.sleep_ms(14) t.deinit() diff --git a/tests/extmod/urandom_basic.py b/tests/extmod/random_basic.py similarity index 81% rename from tests/extmod/urandom_basic.py rename to tests/extmod/random_basic.py index f7f5a6d6911..7cb992fede2 100644 --- a/tests/extmod/urandom_basic.py +++ b/tests/extmod/random_basic.py @@ -1,11 +1,8 @@ try: - import urandom as random + import random except ImportError: - try: - import random - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # check getrandbits returns a value within the bit range for b in (1, 2, 3, 4, 16, 32): diff --git a/tests/extmod/urandom_basic.py.exp b/tests/extmod/random_basic.py.exp similarity index 100% rename from tests/extmod/urandom_basic.py.exp rename to tests/extmod/random_basic.py.exp diff --git a/tests/extmod/urandom_extra.py b/tests/extmod/random_extra.py similarity index 89% rename from tests/extmod/urandom_extra.py rename to tests/extmod/random_extra.py index 78e17379dc6..aa05053377b 100644 --- a/tests/extmod/urandom_extra.py +++ b/tests/extmod/random_extra.py @@ -1,11 +1,8 @@ try: - import urandom as random + import random except ImportError: - try: - import random - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: random.randint diff --git a/tests/extmod/urandom_extra_float.py b/tests/extmod/random_extra_float.py similarity index 72% rename from tests/extmod/urandom_extra_float.py rename to tests/extmod/random_extra_float.py index 65918da1369..3b37ed8dcef 100644 --- a/tests/extmod/urandom_extra_float.py +++ b/tests/extmod/random_extra_float.py @@ -1,11 +1,8 @@ try: - import urandom as random + import random except ImportError: - try: - import random - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: random.randint diff --git a/tests/extmod/urandom_seed_default.py b/tests/extmod/random_seed_default.py similarity index 69% rename from tests/extmod/urandom_seed_default.py rename to tests/extmod/random_seed_default.py index a032b9362b7..2fb16282ca3 100644 --- a/tests/extmod/urandom_seed_default.py +++ b/tests/extmod/random_seed_default.py @@ -1,13 +1,10 @@ -# test urandom.seed() without any arguments +# test random.seed() without any arguments try: - import urandom as random + import random except ImportError: - try: - import random - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: random.seed() diff --git a/tests/extmod/ure1.py b/tests/extmod/re1.py similarity index 95% rename from tests/extmod/ure1.py rename to tests/extmod/re1.py index 2bdf2d0cfb4..7e3839ae24f 100644 --- a/tests/extmod/ure1.py +++ b/tests/extmod/re1.py @@ -1,11 +1,8 @@ try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit r = re.compile(".+") m = r.match("abc") diff --git a/tests/extmod/ure_debug.py b/tests/extmod/re_debug.py similarity index 65% rename from tests/extmod/ure_debug.py rename to tests/extmod/re_debug.py index 7a07ede2d43..0f4c95551f9 100644 --- a/tests/extmod/ure_debug.py +++ b/tests/extmod/re_debug.py @@ -1,10 +1,10 @@ # test printing debugging info when compiling try: - import ure + import re - ure.DEBUG + re.DEBUG except (ImportError, AttributeError): print("SKIP") raise SystemExit -ure.compile("^a|b[0-9]\w$", ure.DEBUG) +re.compile("^a|b[0-9]\w$", re.DEBUG) diff --git a/tests/extmod/ure_debug.py.exp b/tests/extmod/re_debug.py.exp similarity index 100% rename from tests/extmod/ure_debug.py.exp rename to tests/extmod/re_debug.py.exp diff --git a/tests/extmod/ure_error.py b/tests/extmod/re_error.py similarity index 73% rename from tests/extmod/ure_error.py rename to tests/extmod/re_error.py index 52a96b7c038..f61d0913289 100644 --- a/tests/extmod/ure_error.py +++ b/tests/extmod/re_error.py @@ -1,13 +1,10 @@ # test errors in regex try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def test_re(r): diff --git a/tests/extmod/ure_group.py b/tests/extmod/re_group.py similarity index 81% rename from tests/extmod/ure_group.py rename to tests/extmod/re_group.py index 41425dd6234..06c9ccfb2de 100644 --- a/tests/extmod/ure_group.py +++ b/tests/extmod/re_group.py @@ -1,13 +1,10 @@ # test groups, and nested groups try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def print_groups(match): diff --git a/tests/extmod/ure_groups.py b/tests/extmod/re_groups.py similarity index 81% rename from tests/extmod/ure_groups.py rename to tests/extmod/re_groups.py index 7da072a9206..840a4b1af13 100644 --- a/tests/extmod/ure_groups.py +++ b/tests/extmod/re_groups.py @@ -1,13 +1,10 @@ # test match.groups() try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: m = re.match(".", "a") diff --git a/tests/extmod/ure_limit.py b/tests/extmod/re_limit.py similarity index 88% rename from tests/extmod/ure_limit.py rename to tests/extmod/re_limit.py index 99c6a818e85..e0531afbdc8 100644 --- a/tests/extmod/ure_limit.py +++ b/tests/extmod/re_limit.py @@ -1,7 +1,7 @@ -# Test overflow in ure.compile output code. +# Test overflow in re.compile output code. try: - import ure as re + import re except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ure_limit.py.exp b/tests/extmod/re_limit.py.exp similarity index 100% rename from tests/extmod/ure_limit.py.exp rename to tests/extmod/re_limit.py.exp diff --git a/tests/extmod/ure_namedclass.py b/tests/extmod/re_namedclass.py similarity index 85% rename from tests/extmod/ure_namedclass.py rename to tests/extmod/re_namedclass.py index 4afc09dc0ab..442172f4ab0 100644 --- a/tests/extmod/ure_namedclass.py +++ b/tests/extmod/re_namedclass.py @@ -1,13 +1,10 @@ # test named char classes try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def print_groups(match): diff --git a/tests/extmod/ure_span.py b/tests/extmod/re_span.py similarity index 85% rename from tests/extmod/ure_span.py rename to tests/extmod/re_span.py index 03a3fef9f3d..d00ef957a11 100644 --- a/tests/extmod/ure_span.py +++ b/tests/extmod/re_span.py @@ -1,13 +1,10 @@ # test match.span(), and nested spans try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: m = re.match(".", "a") diff --git a/tests/extmod/ure_split.py b/tests/extmod/re_split.py similarity index 82% rename from tests/extmod/ure_split.py rename to tests/extmod/re_split.py index 7e6ef3990f4..7769e1a121d 100644 --- a/tests/extmod/ure_split.py +++ b/tests/extmod/re_split.py @@ -1,11 +1,8 @@ try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit r = re.compile(" ") s = r.split("a b c foobar") diff --git a/tests/extmod/ure_split_empty.py b/tests/extmod/re_split_empty.py similarity index 95% rename from tests/extmod/ure_split_empty.py rename to tests/extmod/re_split_empty.py index 76ce97ea67d..bc17aa8d783 100644 --- a/tests/extmod/ure_split_empty.py +++ b/tests/extmod/re_split_empty.py @@ -5,7 +5,7 @@ # splitting as soon as an empty match is found. try: - import ure as re + import re except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ure_split_empty.py.exp b/tests/extmod/re_split_empty.py.exp similarity index 100% rename from tests/extmod/ure_split_empty.py.exp rename to tests/extmod/re_split_empty.py.exp diff --git a/tests/extmod/ure_split_notimpl.py b/tests/extmod/re_split_notimpl.py similarity index 89% rename from tests/extmod/ure_split_notimpl.py rename to tests/extmod/re_split_notimpl.py index 51bad791efb..7ddec9fa03a 100644 --- a/tests/extmod/ure_split_notimpl.py +++ b/tests/extmod/re_split_notimpl.py @@ -1,5 +1,5 @@ try: - import ure as re + import re except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ure_split_notimpl.py.exp b/tests/extmod/re_split_notimpl.py.exp similarity index 100% rename from tests/extmod/ure_split_notimpl.py.exp rename to tests/extmod/re_split_notimpl.py.exp diff --git a/tests/extmod/re_stack_overflow.py b/tests/extmod/re_stack_overflow.py new file mode 100644 index 00000000000..90fb8296b12 --- /dev/null +++ b/tests/extmod/re_stack_overflow.py @@ -0,0 +1,10 @@ +try: + import re +except ImportError: + print("SKIP") + raise SystemExit + +try: + re.match("(a*)*", "aaa") +except RuntimeError: + print("RuntimeError") diff --git a/tests/extmod/ure_stack_overflow.py.exp b/tests/extmod/re_stack_overflow.py.exp similarity index 100% rename from tests/extmod/ure_stack_overflow.py.exp rename to tests/extmod/re_stack_overflow.py.exp diff --git a/tests/extmod/ure_sub.py b/tests/extmod/re_sub.py similarity index 93% rename from tests/extmod/ure_sub.py rename to tests/extmod/re_sub.py index 806c3895762..229c0e63eed 100644 --- a/tests/extmod/ure_sub.py +++ b/tests/extmod/re_sub.py @@ -1,11 +1,8 @@ try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: re.sub diff --git a/tests/extmod/ure_sub_unmatched.py b/tests/extmod/re_sub_unmatched.py similarity index 71% rename from tests/extmod/ure_sub_unmatched.py rename to tests/extmod/re_sub_unmatched.py index d6312bfc2cb..c238a7ed64b 100644 --- a/tests/extmod/ure_sub_unmatched.py +++ b/tests/extmod/re_sub_unmatched.py @@ -1,13 +1,10 @@ # test re.sub with unmatched groups, behaviour changed in CPython 3.5 try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: re.sub diff --git a/tests/extmod/ure_sub_unmatched.py.exp b/tests/extmod/re_sub_unmatched.py.exp similarity index 100% rename from tests/extmod/ure_sub_unmatched.py.exp rename to tests/extmod/re_sub_unmatched.py.exp diff --git a/tests/extmod/uselect_poll_basic.py b/tests/extmod/select_poll_basic.py similarity index 69% rename from tests/extmod/uselect_poll_basic.py rename to tests/extmod/select_poll_basic.py index 97fbd6fd158..b36e16f0186 100644 --- a/tests/extmod/uselect_poll_basic.py +++ b/tests/extmod/select_poll_basic.py @@ -1,13 +1,10 @@ try: - import usocket as socket, uselect as select, uerrno as errno -except ImportError: - try: - import socket, select, errno - - select.poll # Raises AttributeError for CPython implementations without poll() - except (ImportError, AttributeError): - print("SKIP") - raise SystemExit + import socket, select, errno + + select.poll # Raises AttributeError for CPython implementations without poll() +except (ImportError, AttributeError): + print("SKIP") + raise SystemExit poller = select.poll() diff --git a/tests/extmod/uselect_poll_udp.py b/tests/extmod/select_poll_udp.py similarity index 66% rename from tests/extmod/uselect_poll_udp.py rename to tests/extmod/select_poll_udp.py index 2a56a122b5f..336f987c120 100644 --- a/tests/extmod/uselect_poll_udp.py +++ b/tests/extmod/select_poll_udp.py @@ -1,15 +1,12 @@ # test select.poll on UDP sockets try: - import usocket as socket, uselect as select -except ImportError: - try: - import socket, select + import socket, select - select.poll # Raises AttributeError for CPython implementations without poll() - except (ImportError, AttributeError): - print("SKIP") - raise SystemExit + select.poll # Raises AttributeError for CPython implementations without poll() +except (ImportError, AttributeError): + print("SKIP") + raise SystemExit s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) diff --git a/tests/extmod/usocket_tcp_basic.py b/tests/extmod/socket_tcp_basic.py similarity index 60% rename from tests/extmod/usocket_tcp_basic.py rename to tests/extmod/socket_tcp_basic.py index c2fe8cd14cc..ebd30f7862c 100644 --- a/tests/extmod/usocket_tcp_basic.py +++ b/tests/extmod/socket_tcp_basic.py @@ -1,13 +1,10 @@ # Test basic, stand-alone TCP socket functionality try: - import usocket as socket, uerrno as errno + import socket, errno except ImportError: - try: - import socket, errno - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # recv() on a fresh socket should raise ENOTCONN s = socket.socket() diff --git a/tests/extmod/usocket_udp_nonblock.py b/tests/extmod/socket_udp_nonblock.py similarity index 63% rename from tests/extmod/usocket_udp_nonblock.py rename to tests/extmod/socket_udp_nonblock.py index bc560de142e..f7ce5f34448 100644 --- a/tests/extmod/usocket_udp_nonblock.py +++ b/tests/extmod/socket_udp_nonblock.py @@ -1,13 +1,10 @@ # test non-blocking UDP sockets try: - import usocket as socket, uerrno as errno + import socket, errno except ImportError: - try: - import socket, errno - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) diff --git a/tests/extmod/ussl_basic.py b/tests/extmod/ssl_basic.py similarity index 96% rename from tests/extmod/ussl_basic.py rename to tests/extmod/ssl_basic.py index dd3b6f0b91e..d035798c986 100644 --- a/tests/extmod/ussl_basic.py +++ b/tests/extmod/ssl_basic.py @@ -1,8 +1,8 @@ # very basic test of ssl module, just to test the methods exist try: - import uio as io - import ussl as ssl + import io + import ssl except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ussl_basic.py.exp b/tests/extmod/ssl_basic.py.exp similarity index 100% rename from tests/extmod/ussl_basic.py.exp rename to tests/extmod/ssl_basic.py.exp diff --git a/tests/extmod/ussl_keycert.py b/tests/extmod/ssl_keycert.py similarity index 94% rename from tests/extmod/ussl_keycert.py rename to tests/extmod/ssl_keycert.py index 87a40a1e552..53f064fdaff 100644 --- a/tests/extmod/ussl_keycert.py +++ b/tests/extmod/ssl_keycert.py @@ -1,8 +1,8 @@ -# Test ussl with key/cert passed in +# Test ssl with key/cert passed in try: - import uio as io - import ussl as ssl + import io + import ssl except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ussl_keycert.py.exp b/tests/extmod/ssl_keycert.py.exp similarity index 100% rename from tests/extmod/ussl_keycert.py.exp rename to tests/extmod/ssl_keycert.py.exp diff --git a/tests/extmod/ussl_poll.py b/tests/extmod/ssl_poll.py similarity index 94% rename from tests/extmod/ussl_poll.py rename to tests/extmod/ssl_poll.py index 8080ec51122..347e5f7d37a 100644 --- a/tests/extmod/ussl_poll.py +++ b/tests/extmod/ssl_poll.py @@ -1,8 +1,8 @@ try: - import uselect - import ussl + import select + import ssl import io - import ubinascii as binascii + import binascii except ImportError: print("SKIP") raise SystemExit @@ -121,9 +121,9 @@ def assert_raises(cb, *args, **kwargs): client_io.block_reads = True client_io.block_writes = True -client_sock = ussl.wrap_socket(client_io, do_handshake=False) +client_sock = ssl.wrap_socket(client_io, do_handshake=False) -server_sock = ussl.wrap_socket(server_io, key=key, cert=cert, server_side=True, do_handshake=False) +server_sock = ssl.wrap_socket(server_io, key=key, cert=cert, server_side=True, do_handshake=False) # Do a test read, at this point the TLS handshake wants to write, # so it returns None: @@ -175,7 +175,7 @@ def assert_raises(cb, *args, **kwargs): # Polling on a closed socket errors out: client_io, _ = _Pipe.new_pair() -client_sock = ussl.wrap_socket(client_io, do_handshake=False) +client_sock = ssl.wrap_socket(client_io, do_handshake=False) client_sock.close() assert_poll( client_sock, client_io, _MP_STREAM_POLL_RD, None, _MP_STREAM_POLL_NVAL @@ -184,7 +184,7 @@ def assert_raises(cb, *args, **kwargs): # Errors propagates to poll: client_io, server_io = _Pipe.new_pair() -client_sock = ussl.wrap_socket(client_io, do_handshake=False) +client_sock = ssl.wrap_socket(client_io, do_handshake=False) # The server returns garbage: server_io.write(b"fooba") # Needs to be exactly 5 bytes diff --git a/tests/extmod/ussl_poll.py.exp b/tests/extmod/ssl_poll.py.exp similarity index 100% rename from tests/extmod/ussl_poll.py.exp rename to tests/extmod/ssl_poll.py.exp diff --git a/tests/extmod/ticks_add.py b/tests/extmod/ticks_add.py index 2f1ba6c8109..4f465f3cfba 100644 --- a/tests/extmod/ticks_add.py +++ b/tests/extmod/ticks_add.py @@ -1,5 +1,5 @@ try: - from utime import ticks_diff, ticks_add + from time import ticks_diff, ticks_add except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ticks_diff.py b/tests/extmod/ticks_diff.py index de45a557afc..b2445f0d624 100644 --- a/tests/extmod/ticks_diff.py +++ b/tests/extmod/ticks_diff.py @@ -1,5 +1,5 @@ try: - from utime import ticks_diff, ticks_add + from time import ticks_diff, ticks_add except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/time_ms_us.py b/tests/extmod/time_ms_us.py index ac2ed8be27e..e26c6e677a9 100644 --- a/tests/extmod/time_ms_us.py +++ b/tests/extmod/time_ms_us.py @@ -1,23 +1,23 @@ try: - import utime + import time - utime.sleep_ms, utime.sleep_us, utime.ticks_diff, utime.ticks_ms, utime.ticks_us, utime.ticks_cpu + time.sleep_ms, time.sleep_us, time.ticks_diff, time.ticks_ms, time.ticks_us, time.ticks_cpu except (ImportError, AttributeError): print("SKIP") raise SystemExit -utime.sleep_ms(1) -utime.sleep_us(1) +time.sleep_ms(1) +time.sleep_us(1) -t0 = utime.ticks_ms() -t1 = utime.ticks_ms() -print(0 <= utime.ticks_diff(t1, t0) <= 1) +t0 = time.ticks_ms() +t1 = time.ticks_ms() +print(0 <= time.ticks_diff(t1, t0) <= 1) -t0 = utime.ticks_us() -t1 = utime.ticks_us() -print(0 <= utime.ticks_diff(t1, t0) <= 500) +t0 = time.ticks_us() +t1 = time.ticks_us() +print(0 <= time.ticks_diff(t1, t0) <= 500) # ticks_cpu may not be implemented, at least make sure it doesn't decrease -t0 = utime.ticks_cpu() -t1 = utime.ticks_cpu() -print(utime.ticks_diff(t1, t0) >= 0) +t0 = time.ticks_cpu() +t1 = time.ticks_cpu() +print(time.ticks_diff(t1, t0) >= 0) diff --git a/tests/extmod/utime_res.py b/tests/extmod/time_res.py similarity index 80% rename from tests/extmod/utime_res.py rename to tests/extmod/time_res.py index 4b624334836..548bef1f174 100644 --- a/tests/extmod/utime_res.py +++ b/tests/extmod/time_res.py @@ -1,18 +1,18 @@ -# test utime resolutions +# test time resolutions try: - import utime + import time except ImportError: print("SKIP") raise SystemExit def gmtime_time(): - return utime.gmtime(utime.time()) + return time.gmtime(time.time()) def localtime_time(): - return utime.localtime(utime.time()) + return time.localtime(time.time()) def test(): @@ -32,12 +32,12 @@ def test(): # call time functions results_map = {} - end_time = utime.ticks_ms() + TEST_TIME - while utime.ticks_diff(end_time, utime.ticks_ms()) > 0: - utime.sleep_ms(100) + end_time = time.ticks_ms() + TEST_TIME + while time.ticks_diff(end_time, time.ticks_ms()) > 0: + time.sleep_ms(100) for func_name, _ in EXPECTED_MAP: try: - time_func = getattr(utime, func_name, None) or globals()[func_name] + time_func = getattr(time, func_name, None) or globals()[func_name] now = time_func() # may raise AttributeError except (KeyError, AttributeError): continue diff --git a/tests/extmod/utime_res.py.exp b/tests/extmod/time_res.py.exp similarity index 100% rename from tests/extmod/utime_res.py.exp rename to tests/extmod/time_res.py.exp diff --git a/tests/extmod/utime_time_ns.py b/tests/extmod/time_time_ns.py similarity index 68% rename from tests/extmod/utime_time_ns.py rename to tests/extmod/time_time_ns.py index 0d13f839d4f..3ef58e56a94 100644 --- a/tests/extmod/utime_time_ns.py +++ b/tests/extmod/time_time_ns.py @@ -1,18 +1,18 @@ -# test utime.time_ns() +# test time.time_ns() try: - import utime + import time - utime.sleep_us - utime.time_ns + time.sleep_us + time.time_ns except (ImportError, AttributeError): print("SKIP") raise SystemExit -t0 = utime.time_ns() -utime.sleep_us(5000) -t1 = utime.time_ns() +t0 = time.time_ns() +time.sleep_us(5000) +t1 = time.time_ns() # Check that time_ns increases. print(t0 < t1) diff --git a/tests/extmod/utime_time_ns.py.exp b/tests/extmod/time_time_ns.py.exp similarity index 100% rename from tests/extmod/utime_time_ns.py.exp rename to tests/extmod/time_time_ns.py.exp diff --git a/tests/extmod/utimeq1.py b/tests/extmod/timeq1.py similarity index 90% rename from tests/extmod/utimeq1.py rename to tests/extmod/timeq1.py index 688e5b834ff..0778c872559 100644 --- a/tests/extmod/utimeq1.py +++ b/tests/extmod/timeq1.py @@ -1,8 +1,8 @@ -# Test for utimeq module which implements task queue with support for -# wraparound time (utime.ticks_ms() style). +# Test for timeq module which implements task queue with support for +# wraparound time (time.ticks_ms() style). try: - from utime import ticks_add, ticks_diff - from utimeq import utimeq + from time import ticks_add, ticks_diff + from timeq import timeq except ImportError: print("SKIP") raise SystemExit @@ -24,7 +24,7 @@ def dprint(*v): # Try not to crash on invalid data -h = utimeq(10) +h = timeq(10) try: h.push(1) assert False @@ -45,7 +45,7 @@ def dprint(*v): pass # pushing on full queue -h = utimeq(1) +h = timeq(1) h.push(1, 0, 0) try: h.push(2, 0, 0) @@ -68,7 +68,7 @@ def dprint(*v): # peektime with empty queue try: - utimeq(1).peektime() + timeq(1).peektime() assert False except IndexError: pass @@ -92,7 +92,7 @@ def add(h, v): dprint("-----") -h = utimeq(10) +h = timeq(10) add(h, 0) add(h, MAX) add(h, MAX - 1) @@ -107,7 +107,7 @@ def add(h, v): def edge_case(edge, offset): - h = utimeq(10) + h = timeq(10) add(h, ticks_add(0, offset)) add(h, ticks_add(edge, offset)) dprint(h) diff --git a/tests/extmod/utimeq1.py.exp b/tests/extmod/timeq1.py.exp similarity index 100% rename from tests/extmod/utimeq1.py.exp rename to tests/extmod/timeq1.py.exp diff --git a/tests/extmod/utimeq_stable.py b/tests/extmod/timeq_stable.py similarity index 90% rename from tests/extmod/utimeq_stable.py rename to tests/extmod/timeq_stable.py index 9fb522d5146..b19ea1b3ade 100644 --- a/tests/extmod/utimeq_stable.py +++ b/tests/extmod/timeq_stable.py @@ -1,10 +1,10 @@ try: - from utimeq import utimeq + from timeq import timeq except ImportError: print("SKIP") raise SystemExit -h = utimeq(10) +h = timeq(10) # Check that for 2 same-key items, the queue is stable (pops items # in the same order they were pushed). Unfortunately, this no longer diff --git a/tests/extmod/utimeq_stable.py.exp b/tests/extmod/timeq_stable.py.exp similarity index 100% rename from tests/extmod/utimeq_stable.py.exp rename to tests/extmod/timeq_stable.py.exp diff --git a/tests/extmod/uasyncio_basic.py b/tests/extmod/uasyncio_basic.py index 20c0a82e47a..3858e4fdd52 100644 --- a/tests/extmod/uasyncio_basic.py +++ b/tests/extmod/uasyncio_basic.py @@ -7,15 +7,12 @@ print("SKIP") raise SystemExit +import time -try: - import utime - - ticks = utime.ticks_ms - ticks_diff = utime.ticks_diff -except: - import time - +if hasattr(time, "ticks_ms"): + ticks = time.ticks_ms + ticks_diff = time.ticks_diff +else: ticks = lambda: int(time.time() * 1000) ticks_diff = lambda t1, t0: t1 - t0 diff --git a/tests/extmod/uasyncio_micropython.py b/tests/extmod/uasyncio_micropython.py index a6b65bb2a84..de1687ca8b9 100644 --- a/tests/extmod/uasyncio_micropython.py +++ b/tests/extmod/uasyncio_micropython.py @@ -3,7 +3,7 @@ # - wait_for_ms try: - import utime, uasyncio + import time, uasyncio except ImportError: print("SKIP") raise SystemExit @@ -18,13 +18,13 @@ async def task(id, t): async def main(): # Simple sleep_ms - t0 = utime.ticks_ms() + t0 = time.ticks_ms() await uasyncio.sleep_ms(1) - print(utime.ticks_diff(utime.ticks_ms(), t0) < 100) + print(time.ticks_diff(time.ticks_ms(), t0) < 100) try: # Sleep 1ms beyond maximum allowed sleep value - await uasyncio.sleep_ms(utime.ticks_add(0, -1) // 2 + 1) + await uasyncio.sleep_ms(time.ticks_add(0, -1) // 2 + 1) except OverflowError: print("OverflowError") diff --git a/tests/extmod/uasyncio_threadsafeflag.py b/tests/extmod/uasyncio_threadsafeflag.py index a8a08d2e925..f97b138498d 100644 --- a/tests/extmod/uasyncio_threadsafeflag.py +++ b/tests/extmod/uasyncio_threadsafeflag.py @@ -18,7 +18,7 @@ try: # Unix port can't select/poll on user-defined types. - import uselect as select + import select poller = select.poll() poller.register(asyncio.ThreadSafeFlag()) diff --git a/tests/extmod/uasyncio_wait_task.py b/tests/extmod/uasyncio_wait_task.py index e19e29903cc..1d70ddf7203 100644 --- a/tests/extmod/uasyncio_wait_task.py +++ b/tests/extmod/uasyncio_wait_task.py @@ -10,14 +10,12 @@ raise SystemExit -try: - import utime - - ticks = utime.ticks_ms - ticks_diff = utime.ticks_diff -except: - import time +import time +if hasattr(time, "ticks_ms"): + ticks = time.ticks_ms + ticks_diff = time.ticks_diff +else: ticks = lambda: int(time.time() * 1000) ticks_diff = lambda t1, t0: t1 - t0 diff --git a/tests/extmod/uctypes_array_assign_native_le.py b/tests/extmod/uctypes_array_assign_native_le.py index 5bddfcdf2f6..d4c27fc4b3f 100644 --- a/tests/extmod/uctypes_array_assign_native_le.py +++ b/tests/extmod/uctypes_array_assign_native_le.py @@ -1,4 +1,4 @@ -import usys +import sys try: import uctypes @@ -6,7 +6,7 @@ print("SKIP") raise SystemExit -if usys.byteorder != "little": +if sys.byteorder != "little": print("SKIP") raise SystemExit diff --git a/tests/extmod/uctypes_array_assign_native_le_intbig.py b/tests/extmod/uctypes_array_assign_native_le_intbig.py index 42583b8afef..f33c63b4ef9 100644 --- a/tests/extmod/uctypes_array_assign_native_le_intbig.py +++ b/tests/extmod/uctypes_array_assign_native_le_intbig.py @@ -1,4 +1,4 @@ -import usys +import sys try: import uctypes @@ -6,7 +6,7 @@ print("SKIP") raise SystemExit -if usys.byteorder != "little": +if sys.byteorder != "little": print("SKIP") raise SystemExit diff --git a/tests/extmod/uctypes_native_le.py b/tests/extmod/uctypes_native_le.py index 9889b98e9d0..7958e5c22ad 100644 --- a/tests/extmod/uctypes_native_le.py +++ b/tests/extmod/uctypes_native_le.py @@ -1,7 +1,7 @@ # This test is exactly like uctypes_le.py, but uses native structure layout. # Codepaths for packed vs native structures are different. This test only works # on little-endian machine (no matter if 32 or 64 bit). -import usys +import sys try: import uctypes @@ -9,7 +9,7 @@ print("SKIP") raise SystemExit -if usys.byteorder != "little": +if sys.byteorder != "little": print("SKIP") raise SystemExit diff --git a/tests/extmod/uctypes_ptr_le.py b/tests/extmod/uctypes_ptr_le.py index f475465ae80..5d8094ee48a 100644 --- a/tests/extmod/uctypes_ptr_le.py +++ b/tests/extmod/uctypes_ptr_le.py @@ -1,4 +1,4 @@ -import usys +import sys try: import uctypes @@ -6,7 +6,7 @@ print("SKIP") raise SystemExit -if usys.byteorder != "little": +if sys.byteorder != "little": print("SKIP") raise SystemExit diff --git a/tests/extmod/uctypes_ptr_native_le.py b/tests/extmod/uctypes_ptr_native_le.py index ca2b316c54a..8ca4d2c55cf 100644 --- a/tests/extmod/uctypes_ptr_native_le.py +++ b/tests/extmod/uctypes_ptr_native_le.py @@ -1,4 +1,4 @@ -import usys +import sys try: import uctypes @@ -6,7 +6,7 @@ print("SKIP") raise SystemExit -if usys.byteorder != "little": +if sys.byteorder != "little": print("SKIP") raise SystemExit diff --git a/tests/extmod/uctypes_sizeof_od.py b/tests/extmod/uctypes_sizeof_od.py index 2f070095b55..375f05f5e2c 100644 --- a/tests/extmod/uctypes_sizeof_od.py +++ b/tests/extmod/uctypes_sizeof_od.py @@ -1,5 +1,5 @@ try: - from ucollections import OrderedDict + from collections import OrderedDict import uctypes except ImportError: print("SKIP") diff --git a/tests/extmod/uhashlib_md5.py b/tests/extmod/uhashlib_md5.py deleted file mode 100644 index 07d5f316920..00000000000 --- a/tests/extmod/uhashlib_md5.py +++ /dev/null @@ -1,21 +0,0 @@ -try: - import uhashlib as hashlib -except ImportError: - try: - import hashlib - except ImportError: - # This is neither uPy, nor cPy, so must be uPy with - # uhashlib module disabled. - print("SKIP") - raise SystemExit - -try: - hashlib.md5 -except AttributeError: - # MD5 is only available on some ports - print("SKIP") - raise SystemExit - -md5 = hashlib.md5(b"hello") -md5.update(b"world") -print(md5.digest()) diff --git a/tests/extmod/uhashlib_sha1.py b/tests/extmod/uhashlib_sha1.py deleted file mode 100644 index a5731213165..00000000000 --- a/tests/extmod/uhashlib_sha1.py +++ /dev/null @@ -1,21 +0,0 @@ -try: - import uhashlib as hashlib -except ImportError: - try: - import hashlib - except ImportError: - # This is neither uPy, nor cPy, so must be uPy with - # uhashlib module disabled. - print("SKIP") - raise SystemExit - -try: - hashlib.sha1 -except AttributeError: - # SHA1 is only available on some ports - print("SKIP") - raise SystemExit - -sha1 = hashlib.sha1(b"hello") -sha1.update(b"world") -print(sha1.digest()) diff --git a/tests/extmod/ujson_dumps_extra.py b/tests/extmod/ujson_dumps_extra.py deleted file mode 100644 index f2aa7f249fc..00000000000 --- a/tests/extmod/ujson_dumps_extra.py +++ /dev/null @@ -1,9 +0,0 @@ -# test uPy ujson behaviour that's not valid in CPy - -try: - import ujson -except ImportError: - print("SKIP") - raise SystemExit - -print(ujson.dumps(b"1234")) diff --git a/tests/extmod/ujson_dumps_float.py b/tests/extmod/ujson_dumps_float.py deleted file mode 100644 index 25681d0c23c..00000000000 --- a/tests/extmod/ujson_dumps_float.py +++ /dev/null @@ -1,11 +0,0 @@ -try: - import ujson as json -except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit - -print(json.dumps(1.2)) -print(json.dumps({1.5: "hi"})) diff --git a/tests/extmod/ujson_dumps_ordereddict.py b/tests/extmod/ujson_dumps_ordereddict.py deleted file mode 100644 index c6f4a8fcb79..00000000000 --- a/tests/extmod/ujson_dumps_ordereddict.py +++ /dev/null @@ -1,12 +0,0 @@ -try: - import ujson as json - from ucollections import OrderedDict -except ImportError: - try: - import json - from collections import OrderedDict - except ImportError: - print("SKIP") - raise SystemExit - -print(json.dumps(OrderedDict(((1, 2), (3, 4))))) diff --git a/tests/extmod/ujson_load.py b/tests/extmod/ujson_load.py deleted file mode 100644 index 7cec9246b82..00000000000 --- a/tests/extmod/ujson_load.py +++ /dev/null @@ -1,15 +0,0 @@ -try: - from uio import StringIO - import ujson as json -except: - try: - from io import StringIO - import json - except ImportError: - print("SKIP") - raise SystemExit - -print(json.load(StringIO("null"))) -print(json.load(StringIO('"abc\\u0064e"'))) -print(json.load(StringIO("[false, true, 1, -2]"))) -print(json.load(StringIO('{"a":true}'))) diff --git a/tests/extmod/ure_stack_overflow.py b/tests/extmod/ure_stack_overflow.py deleted file mode 100644 index d3ce0c5a7b1..00000000000 --- a/tests/extmod/ure_stack_overflow.py +++ /dev/null @@ -1,13 +0,0 @@ -try: - import ure as re -except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit - -try: - re.match("(a*)*", "aaa") -except RuntimeError: - print("RuntimeError") diff --git a/tests/extmod/vfs_basic.py b/tests/extmod/vfs_basic.py index 9a9ef2ca61b..028846406a1 100644 --- a/tests/extmod/vfs_basic.py +++ b/tests/extmod/vfs_basic.py @@ -1,9 +1,9 @@ # test VFS functionality without any particular filesystem type try: - import uos + import os - uos.mount + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -59,35 +59,35 @@ def open(self, file, mode): # first we umount any existing mount points the target may have try: - uos.umount("/") + os.umount("/") except OSError: pass -for path in uos.listdir("/"): - uos.umount("/" + path) +for path in os.listdir("/"): + os.umount("/" + path) # stat root dir -print(uos.stat("/")) +print(os.stat("/")) # statvfs root dir; verify that f_namemax has a sensible size -print(uos.statvfs("/")[9] >= 32) +print(os.statvfs("/")[9] >= 32) # getcwd when in root dir -print(uos.getcwd()) +print(os.getcwd()) # test operations on the root directory with nothing mounted, they should all fail for func in ("chdir", "listdir", "mkdir", "remove", "rmdir", "stat"): for arg in ("x", "/x"): try: - getattr(uos, func)(arg) + getattr(os, func)(arg) except OSError: print(func, arg, "OSError") # basic mounting and listdir -uos.mount(Filesystem(1), "/test_mnt") -print(uos.listdir()) +os.mount(Filesystem(1), "/test_mnt") +print(os.listdir()) # ilistdir -i = uos.ilistdir() +i = os.ilistdir() print(next(i)) try: next(i) @@ -99,88 +99,88 @@ def open(self, file, mode): print("StopIteration") # referencing the mount point in different ways -print(uos.listdir("test_mnt")) -print(uos.listdir("/test_mnt")) +print(os.listdir("test_mnt")) +print(os.listdir("/test_mnt")) # mounting another filesystem -uos.mount(Filesystem(2), "/test_mnt2", readonly=True) -print(uos.listdir()) -print(uos.listdir("/test_mnt2")) +os.mount(Filesystem(2), "/test_mnt2", readonly=True) +print(os.listdir()) +print(os.listdir("/test_mnt2")) # mounting over an existing mount point try: - uos.mount(Filesystem(3), "/test_mnt2") + os.mount(Filesystem(3), "/test_mnt2") except OSError: print("OSError") # mkdir of a mount point try: - uos.mkdir("/test_mnt") + os.mkdir("/test_mnt") except OSError: print("OSError") # rename across a filesystem try: - uos.rename("/test_mnt/a", "/test_mnt2/b") + os.rename("/test_mnt/a", "/test_mnt2/b") except OSError: print("OSError") # delegating to mounted filesystem -uos.chdir("test_mnt") -print(uos.listdir()) -print(uos.getcwd()) -uos.mkdir("test_dir") -uos.remove("test_file") -uos.rename("test_file", "test_file2") -uos.rmdir("test_dir") -print(uos.stat("test_file")) -print(uos.statvfs("/test_mnt")) +os.chdir("test_mnt") +print(os.listdir()) +print(os.getcwd()) +os.mkdir("test_dir") +os.remove("test_file") +os.rename("test_file", "test_file2") +os.rmdir("test_dir") +print(os.stat("test_file")) +print(os.statvfs("/test_mnt")) open("test_file") open("test_file", "wb") # umount -uos.umount("/test_mnt") -uos.umount("/test_mnt2") +os.umount("/test_mnt") +os.umount("/test_mnt2") # umount a non-existent mount point try: - uos.umount("/test_mnt") + os.umount("/test_mnt") except OSError: print("OSError") # root dir -uos.mount(Filesystem(3), "/") -print(uos.stat("/")) -print(uos.statvfs("/")) -print(uos.listdir()) +os.mount(Filesystem(3), "/") +print(os.stat("/")) +print(os.statvfs("/")) +print(os.listdir()) open("test") -uos.mount(Filesystem(4), "/mnt") -print(uos.listdir()) -print(uos.listdir("/mnt")) -uos.chdir("/mnt") -print(uos.listdir()) +os.mount(Filesystem(4), "/mnt") +print(os.listdir()) +print(os.listdir("/mnt")) +os.chdir("/mnt") +print(os.listdir()) # chdir to a subdir within root-mounted vfs, and then listdir -uos.chdir("/subdir") -print(uos.listdir()) -uos.chdir("/") +os.chdir("/subdir") +print(os.listdir()) +os.chdir("/") -uos.umount("/") -print(uos.listdir("/")) -uos.umount("/mnt") +os.umount("/") +print(os.listdir("/")) +os.umount("/mnt") # chdir to a non-existent mount point (current directory should remain unchanged) try: - uos.chdir("/foo") + os.chdir("/foo") except OSError: print("OSError") -print(uos.getcwd()) +print(os.getcwd()) # chdir to a non-existent subdirectory in a mounted filesystem -uos.mount(Filesystem(5, 1), "/mnt") +os.mount(Filesystem(5, 1), "/mnt") try: - uos.chdir("/mnt/subdir") + os.chdir("/mnt/subdir") except OSError: print("OSError") -print(uos.getcwd()) +print(os.getcwd()) diff --git a/tests/extmod/vfs_blockdev.py b/tests/extmod/vfs_blockdev.py index e24169ba936..f4c84ea9213 100644 --- a/tests/extmod/vfs_blockdev.py +++ b/tests/extmod/vfs_blockdev.py @@ -1,10 +1,10 @@ # Test for behaviour of combined standard and extended block device try: - import uos + import os - uos.VfsFat - uos.VfsLfs2 + os.VfsFat + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -65,10 +65,12 @@ def test(bdev, vfs_class): try: + import os + bdev = RAMBlockDevice(50) except MemoryError: print("SKIP") raise SystemExit -test(bdev, uos.VfsFat) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsFat) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_fat_fileio1.py b/tests/extmod/vfs_fat_fileio1.py index 55f399ff2ea..f4db5ac8dde 100644 --- a/tests/extmod/vfs_fat_fileio1.py +++ b/tests/extmod/vfs_fat_fileio1.py @@ -1,12 +1,12 @@ try: - import uerrno - import uos + import errno + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -38,14 +38,14 @@ def ioctl(self, op, arg): try: bdev = RAMFS(50) - uos.VfsFat.mkfs(bdev) + os.VfsFat.mkfs(bdev) except MemoryError: print("SKIP") raise SystemExit -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") -uos.chdir("/ramdisk") +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") +os.chdir("/ramdisk") # file IO f = open("foo_file.txt", "w") @@ -57,22 +57,22 @@ def ioctl(self, op, arg): try: f.write("world!") except OSError as e: - print(e.errno == uerrno.EINVAL) + print(e.errno == errno.EINVAL) try: f.read() except OSError as e: - print(e.errno == uerrno.EINVAL) + print(e.errno == errno.EINVAL) try: f.flush() except OSError as e: - print(e.errno == uerrno.EINVAL) + print(e.errno == errno.EINVAL) try: open("foo_file.txt", "x") except OSError as e: - print(e.errno == uerrno.EEXIST) + print(e.errno == errno.EEXIST) with open("foo_file.txt", "a") as f: f.write("world!") @@ -104,7 +104,7 @@ def ioctl(self, op, arg): try: vfs.rmdir("foo_file.txt") except OSError as e: - print(e.errno == 20) # uerrno.ENOTDIR + print(e.errno == 20) # errno.ENOTDIR vfs.remove("foo_file.txt") print(list(vfs.ilistdir())) diff --git a/tests/extmod/vfs_fat_fileio2.py b/tests/extmod/vfs_fat_fileio2.py index 9429f115f62..353b997e5c8 100644 --- a/tests/extmod/vfs_fat_fileio2.py +++ b/tests/extmod/vfs_fat_fileio2.py @@ -1,12 +1,12 @@ try: - import uerrno - import uos + import errno + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -38,34 +38,34 @@ def ioctl(self, op, arg): try: bdev = RAMFS(50) - uos.VfsFat.mkfs(bdev) + os.VfsFat.mkfs(bdev) except MemoryError: print("SKIP") raise SystemExit -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") -uos.chdir("/ramdisk") +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") +os.chdir("/ramdisk") try: vfs.mkdir("foo_dir") except OSError as e: - print(e.errno == uerrno.EEXIST) + print(e.errno == errno.EEXIST) try: vfs.remove("foo_dir") except OSError as e: - print(e.errno == uerrno.EISDIR) + print(e.errno == errno.EISDIR) try: vfs.remove("no_file.txt") except OSError as e: - print(e.errno == uerrno.ENOENT) + print(e.errno == errno.ENOENT) try: vfs.rename("foo_dir", "/null/file") except OSError as e: - print(e.errno == uerrno.ENOENT) + print(e.errno == errno.ENOENT) # file in dir with open("foo_dir/file-in-dir.txt", "w+t") as f: @@ -81,7 +81,7 @@ def ioctl(self, op, arg): try: vfs.rmdir("foo_dir") except OSError as e: - print(e.errno == uerrno.EACCES) + print(e.errno == errno.EACCES) # trim full path vfs.rename("foo_dir/file-in-dir.txt", "foo_dir/file.txt") @@ -110,5 +110,5 @@ def ioctl(self, op, arg): f = open("large_file.txt", "wb") f.write(bytearray(bsize * free)) except OSError as e: - print("ENOSPC:", e.errno == 28) # uerrno.ENOSPC + print("ENOSPC:", e.errno == 28) # errno.ENOSPC f.close() diff --git a/tests/extmod/vfs_fat_finaliser.py b/tests/extmod/vfs_fat_finaliser.py index b38e640c73d..b6c7dffb829 100644 --- a/tests/extmod/vfs_fat_finaliser.py +++ b/tests/extmod/vfs_fat_finaliser.py @@ -1,9 +1,9 @@ # Test VfsFat class and its finaliser try: - import uerrno, uos + import errno, os - uos.VfsFat + os.VfsFat except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -31,14 +31,16 @@ def ioctl(self, op, arg): # Create block device, and skip test if not enough RAM try: + import errno, os + bdev = RAMBlockDevice(50) except MemoryError: print("SKIP") raise SystemExit # Format block device and create VFS object -uos.VfsFat.mkfs(bdev) -vfs = uos.VfsFat(bdev) +os.VfsFat.mkfs(bdev) +vfs = os.VfsFat(bdev) # Here we test that opening a file with the heap locked fails correctly. This # is a special case because file objects use a finaliser and allocating with a @@ -48,6 +50,8 @@ def ioctl(self, op, arg): micropython.heap_lock() try: + import errno, os + vfs.open("x", "r") except MemoryError: print("MemoryError") diff --git a/tests/extmod/vfs_fat_ilistdir_del.py b/tests/extmod/vfs_fat_ilistdir_del.py index ccdacc57c25..055836ad71b 100644 --- a/tests/extmod/vfs_fat_ilistdir_del.py +++ b/tests/extmod/vfs_fat_ilistdir_del.py @@ -2,9 +2,9 @@ import gc try: - import uos + import os - uos.VfsFat + os.VfsFat except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -77,4 +77,4 @@ def test(bdev, vfs_class): print("SKIP") raise SystemExit -test(bdev, uos.VfsFat) +test(bdev, os.VfsFat) diff --git a/tests/extmod/vfs_fat_more.py b/tests/extmod/vfs_fat_more.py index 981c2524a6e..7074221a326 100644 --- a/tests/extmod/vfs_fat_more.py +++ b/tests/extmod/vfs_fat_more.py @@ -1,11 +1,11 @@ try: - import uos + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -44,76 +44,76 @@ def ioctl(self, op, arg): # first we umount any existing mount points the target may have try: - uos.umount("/") + os.umount("/") except OSError: pass -for path in uos.listdir("/"): - uos.umount("/" + path) +for path in os.listdir("/"): + os.umount("/" + path) -uos.VfsFat.mkfs(bdev) -uos.mount(bdev, "/") +os.VfsFat.mkfs(bdev) +os.mount(bdev, "/") -print(uos.getcwd()) +print(os.getcwd()) f = open("test.txt", "w") f.write("hello") f.close() -print(uos.listdir()) -print(uos.listdir("/")) -print(uos.stat("")[:-3]) -print(uos.stat("/")[:-3]) -print(uos.stat("test.txt")[:-3]) -print(uos.stat("/test.txt")[:-3]) +print(os.listdir()) +print(os.listdir("/")) +print(os.stat("")[:-3]) +print(os.stat("/")[:-3]) +print(os.stat("test.txt")[:-3]) +print(os.stat("/test.txt")[:-3]) f = open("/test.txt") print(f.read()) f.close() -uos.rename("test.txt", "test2.txt") -print(uos.listdir()) -uos.rename("test2.txt", "/test3.txt") -print(uos.listdir()) -uos.rename("/test3.txt", "test4.txt") -print(uos.listdir()) -uos.rename("/test4.txt", "/test5.txt") -print(uos.listdir()) - -uos.mkdir("dir") -print(uos.listdir()) -uos.mkdir("/dir2") -print(uos.listdir()) -uos.mkdir("dir/subdir") -print(uos.listdir("dir")) +os.rename("test.txt", "test2.txt") +print(os.listdir()) +os.rename("test2.txt", "/test3.txt") +print(os.listdir()) +os.rename("/test3.txt", "test4.txt") +print(os.listdir()) +os.rename("/test4.txt", "/test5.txt") +print(os.listdir()) + +os.mkdir("dir") +print(os.listdir()) +os.mkdir("/dir2") +print(os.listdir()) +os.mkdir("dir/subdir") +print(os.listdir("dir")) for exist in ("", "/", "dir", "/dir", "dir/subdir"): try: - uos.mkdir(exist) + os.mkdir(exist) except OSError as er: print("mkdir OSError", er.errno == 17) # EEXIST -uos.chdir("/") -print(uos.stat("test5.txt")[:-3]) +os.chdir("/") +print(os.stat("test5.txt")[:-3]) -uos.VfsFat.mkfs(bdev2) -uos.mount(bdev2, "/sys") -print(uos.listdir()) -print(uos.listdir("sys")) -print(uos.listdir("/sys")) +os.VfsFat.mkfs(bdev2) +os.mount(bdev2, "/sys") +print(os.listdir()) +print(os.listdir("sys")) +print(os.listdir("/sys")) -uos.rmdir("dir2") -uos.remove("test5.txt") -print(uos.listdir()) +os.rmdir("dir2") +os.remove("test5.txt") +print(os.listdir()) -uos.umount("/") -print(uos.getcwd()) -print(uos.listdir()) -print(uos.listdir("sys")) +os.umount("/") +print(os.getcwd()) +print(os.listdir()) +print(os.listdir("sys")) # test importing a file from a mounted FS -import usys +import sys -usys.path.clear() -usys.path.append("/sys") +sys.path.clear() +sys.path.append("/sys") with open("sys/test_module.py", "w") as f: f.write('print("test_module!")') import test_module diff --git a/tests/extmod/vfs_fat_mtime.py b/tests/extmod/vfs_fat_mtime.py index d8fd66b75f7..1ceb611364a 100644 --- a/tests/extmod/vfs_fat_mtime.py +++ b/tests/extmod/vfs_fat_mtime.py @@ -1,11 +1,11 @@ # Test for VfsFat using a RAM device, mtime feature try: - import utime, uos + import time, os - utime.time - utime.sleep - uos.VfsFat + time.time + time.sleep + os.VfsFat except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -44,11 +44,11 @@ def test(bdev, vfs_class): vfs = vfs_class(bdev) # Create an empty file, should have a timestamp. - current_time = int(utime.time()) + current_time = int(time.time()) vfs.open("test1", "wt").close() # Wait 2 seconds so mtime will increase (FAT has 2 second resolution). - utime.sleep(2) + time.sleep(2) # Create another empty file, should have a timestamp. vfs.open("test2", "wt").close() @@ -71,4 +71,4 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(50) -test(bdev, uos.VfsFat) +test(bdev, os.VfsFat) diff --git a/tests/extmod/vfs_fat_oldproto.py b/tests/extmod/vfs_fat_oldproto.py index b1556ba2c0e..f5336ba916f 100644 --- a/tests/extmod/vfs_fat_oldproto.py +++ b/tests/extmod/vfs_fat_oldproto.py @@ -1,12 +1,12 @@ try: - import uerrno - import uos + import errno + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -41,9 +41,9 @@ def count(self): print("SKIP") raise SystemExit -uos.VfsFat.mkfs(bdev) -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") +os.VfsFat.mkfs(bdev) +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") # file io with vfs.open("file.txt", "w") as f: diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py index 01235bc2664..1693359d49d 100644 --- a/tests/extmod/vfs_fat_ramdisk.py +++ b/tests/extmod/vfs_fat_ramdisk.py @@ -1,12 +1,12 @@ try: - import uerrno - import uos + import errno + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -38,7 +38,7 @@ def ioctl(self, op, arg): try: bdev = RAMFS(50) - uos.VfsFat.mkfs(bdev) + os.VfsFat.mkfs(bdev) except MemoryError: print("SKIP") raise SystemExit @@ -46,8 +46,8 @@ def ioctl(self, op, arg): print(b"FOO_FILETXT" not in bdev.data) print(b"hello!" not in bdev.data) -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") print("statvfs:", vfs.statvfs("/ramdisk")) print("getcwd:", vfs.getcwd()) @@ -55,7 +55,7 @@ def ioctl(self, op, arg): try: vfs.stat("no_file.txt") except OSError as e: - print(e.errno == uerrno.ENOENT) + print(e.errno == errno.ENOENT) with vfs.open("foo_file.txt", "w") as f: f.write("hello!") @@ -78,18 +78,18 @@ def ioctl(self, op, arg): try: vfs.chdir("sub_file.txt") except OSError as e: - print(e.errno == uerrno.ENOENT) + print(e.errno == errno.ENOENT) vfs.chdir("..") print("getcwd:", vfs.getcwd()) -uos.umount(vfs) +os.umount(vfs) -vfs = uos.VfsFat(bdev) +vfs = os.VfsFat(bdev) print(list(vfs.ilistdir(b""))) # list a non-existent directory try: vfs.ilistdir(b"no_exist") except OSError as e: - print("ENOENT:", e.errno == uerrno.ENOENT) + print("ENOENT:", e.errno == errno.ENOENT) diff --git a/tests/extmod/vfs_fat_ramdisklarge.py b/tests/extmod/vfs_fat_ramdisklarge.py index 649a53db147..40cba9ee430 100644 --- a/tests/extmod/vfs_fat_ramdisklarge.py +++ b/tests/extmod/vfs_fat_ramdisklarge.py @@ -1,13 +1,13 @@ # test making a FAT filesystem on a very large block device try: - import uos + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -46,13 +46,13 @@ def ioctl(self, op, arg): try: bdev = RAMBDevSparse(4 * 1024 * 1024 * 1024 // RAMBDevSparse.SEC_SIZE) - uos.VfsFat.mkfs(bdev) + os.VfsFat.mkfs(bdev) except MemoryError: print("SKIP") raise SystemExit -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") print("statvfs:", vfs.statvfs("/ramdisk")) @@ -66,4 +66,4 @@ def ioctl(self, op, arg): print(f.read()) f.close() -uos.umount(vfs) +os.umount(vfs) diff --git a/tests/extmod/vfs_lfs.py b/tests/extmod/vfs_lfs.py index 8e56400df3c..83377653b2c 100644 --- a/tests/extmod/vfs_lfs.py +++ b/tests/extmod/vfs_lfs.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -150,5 +150,5 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs1) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs1) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_corrupt.py b/tests/extmod/vfs_lfs_corrupt.py index 330458709a3..c49dcad92b4 100644 --- a/tests/extmod/vfs_lfs_corrupt.py +++ b/tests/extmod/vfs_lfs_corrupt.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device, testing error handling from corrupt block device try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -108,5 +108,5 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs1) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs1) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_error.py b/tests/extmod/vfs_lfs_error.py index 717284ea017..32b76b28212 100644 --- a/tests/extmod/vfs_lfs_error.py +++ b/tests/extmod/vfs_lfs_error.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device, testing error handling try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -117,5 +117,5 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs1) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs1) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_file.py b/tests/extmod/vfs_lfs_file.py index 774cca29643..b4a3e6b2236 100644 --- a/tests/extmod/vfs_lfs_file.py +++ b/tests/extmod/vfs_lfs_file.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device, file IO try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -117,5 +117,5 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs1) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs1) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_ilistdir_del.py b/tests/extmod/vfs_lfs_ilistdir_del.py index 073576986d3..ff667171478 100644 --- a/tests/extmod/vfs_lfs_ilistdir_del.py +++ b/tests/extmod/vfs_lfs_ilistdir_del.py @@ -2,9 +2,9 @@ import gc try: - import uos + import os - uos.VfsLfs2 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -72,4 +72,4 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_mount.py b/tests/extmod/vfs_lfs_mount.py index bea8a2723ac..4ebd9ac6233 100644 --- a/tests/extmod/vfs_lfs_mount.py +++ b/tests/extmod/vfs_lfs_mount.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device, with mount/umount try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -42,7 +42,7 @@ def test(vfs_class): # mount bdev unformatted try: - uos.mount(bdev, "/lfs") + os.mount(bdev, "/lfs") except Exception as er: print(repr(er)) @@ -53,7 +53,7 @@ def test(vfs_class): vfs = vfs_class(bdev) # mount - uos.mount(vfs, "/lfs") + os.mount(vfs, "/lfs") # import with open("/lfs/lfsmod.py", "w") as f: @@ -61,23 +61,23 @@ def test(vfs_class): import lfsmod # import package - uos.mkdir("/lfs/lfspkg") + os.mkdir("/lfs/lfspkg") with open("/lfs/lfspkg/__init__.py", "w") as f: f.write('print("package")\n') import lfspkg # chdir and import module from current directory (needs "" in sys.path) - uos.mkdir("/lfs/subdir") - uos.chdir("/lfs/subdir") - uos.rename("/lfs/lfsmod.py", "/lfs/subdir/lfsmod2.py") + os.mkdir("/lfs/subdir") + os.chdir("/lfs/subdir") + os.rename("/lfs/lfsmod.py", "/lfs/subdir/lfsmod2.py") import lfsmod2 # umount - uos.umount("/lfs") + os.umount("/lfs") # mount read-only vfs = vfs_class(bdev) - uos.mount(vfs, "/lfs", readonly=True) + os.mount(vfs, "/lfs", readonly=True) # test reading works with open("/lfs/subdir/lfsmod2.py") as f: @@ -90,25 +90,25 @@ def test(vfs_class): print(repr(er)) # umount - uos.umount("/lfs") + os.umount("/lfs") # mount bdev again - uos.mount(bdev, "/lfs") + os.mount(bdev, "/lfs") # umount - uos.umount("/lfs") + os.umount("/lfs") # clear imported modules - usys.modules.clear() + sys.modules.clear() # initialise path -import usys +import sys -usys.path.clear() -usys.path.append("/lfs") -usys.path.append("") +sys.path.clear() +sys.path.append("/lfs") +sys.path.append("") # run tests -test(uos.VfsLfs1) -test(uos.VfsLfs2) +test(os.VfsLfs1) +test(os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_mtime.py b/tests/extmod/vfs_lfs_mtime.py index a67e48dd80d..ade02fa1449 100644 --- a/tests/extmod/vfs_lfs_mtime.py +++ b/tests/extmod/vfs_lfs_mtime.py @@ -1,11 +1,11 @@ # Test for VfsLfs using a RAM device, mtime feature try: - import utime, uos + import time, os - utime.time - utime.sleep - uos.VfsLfs2 + time.time + time.sleep + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -47,11 +47,11 @@ def test(bdev, vfs_class): vfs = vfs_class(bdev, mtime=True) # Create an empty file, should have a timestamp. - current_time = int(utime.time()) + current_time = int(time.time()) vfs.open("test1", "wt").close() # Wait 1 second so mtime will increase by at least 1. - utime.sleep(1) + time.sleep(1) # Create another empty file, should have a timestamp. vfs.open("test2", "wt").close() @@ -68,7 +68,7 @@ def test(bdev, vfs_class): print(stat1[8] < stat2[8]) # Wait 1 second so mtime will increase by at least 1. - utime.sleep(1) + time.sleep(1) # Open test1 for reading and ensure mtime did not change. vfs.open("test1", "rt").close() @@ -107,4 +107,4 @@ def test(bdev, vfs_class): print("SKIP") raise SystemExit -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_superblock.py b/tests/extmod/vfs_lfs_superblock.py index 1ac5675554b..b8a8ec60b96 100644 --- a/tests/extmod/vfs_lfs_superblock.py +++ b/tests/extmod/vfs_lfs_superblock.py @@ -1,9 +1,9 @@ # Test for VfsLfs using a RAM device, when the first superblock does not exist try: - import uos + import os - uos.VfsLfs2 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -36,12 +36,12 @@ def ioctl(self, op, arg): bdev = RAMBlockDevice(64, lfs2_data) # Create the VFS explicitly, no auto-detection is needed for this. -vfs = uos.VfsLfs2(bdev) +vfs = os.VfsLfs2(bdev) print(list(vfs.ilistdir())) # Mount the block device directly; this relies on auto-detection. -uos.mount(bdev, "/userfs") -print(uos.listdir("/userfs")) +os.mount(bdev, "/userfs") +print(os.listdir("/userfs")) # Clean up. -uos.umount("/userfs") +os.umount("/userfs") diff --git a/tests/extmod/vfs_posix.py b/tests/extmod/vfs_posix.py index 3c23140065a..05dc0f537e3 100644 --- a/tests/extmod/vfs_posix.py +++ b/tests/extmod/vfs_posix.py @@ -2,9 +2,9 @@ try: import gc - import uos + import os - uos.VfsPosix + os.VfsPosix except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -13,27 +13,29 @@ # Skip the test if it does exist. temp_dir = "micropy_test_dir" try: - uos.stat(temp_dir) + import os + + os.stat(temp_dir) print("SKIP") raise SystemExit except OSError: pass # getcwd and chdir -curdir = uos.getcwd() -uos.chdir("/") -print(uos.getcwd()) -uos.chdir(curdir) -print(uos.getcwd() == curdir) +curdir = os.getcwd() +os.chdir("/") +print(os.getcwd()) +os.chdir(curdir) +print(os.getcwd() == curdir) # stat -print(type(uos.stat("/"))) +print(type(os.stat("/"))) # listdir and ilistdir -print(type(uos.listdir("/"))) +print(type(os.listdir("/"))) # mkdir -uos.mkdir(temp_dir) +os.mkdir(temp_dir) # file create f = open(temp_dir + "/test", "w") @@ -78,14 +80,14 @@ def write_files_without_closing(): print("next_file_no <= base_file_no", next_file_no <= base_file_no) for n in names + [basefd, nextfd]: - uos.remove(n) + os.remove(n) # rename -uos.rename(temp_dir + "/test", temp_dir + "/test2") -print(uos.listdir(temp_dir)) +os.rename(temp_dir + "/test", temp_dir + "/test2") +print(os.listdir(temp_dir)) # construct new VfsPosix with path argument -vfs = uos.VfsPosix(temp_dir) +vfs = os.VfsPosix(temp_dir) print(list(i[0] for i in vfs.ilistdir("."))) # stat, statvfs (statvfs may not exist) @@ -98,21 +100,25 @@ def write_files_without_closing(): print(type(list(vfs.ilistdir(b"."))[0][0])) # remove -uos.remove(temp_dir + "/test2") -print(uos.listdir(temp_dir)) +os.remove(temp_dir + "/test2") +print(os.listdir(temp_dir)) # remove with error try: - uos.remove(temp_dir + "/test2") + import os + + os.remove(temp_dir + "/test2") except OSError: print("remove OSError") # rmdir -uos.rmdir(temp_dir) -print(temp_dir in uos.listdir()) +os.rmdir(temp_dir) +print(temp_dir in os.listdir()) # rmdir with error try: - uos.rmdir(temp_dir) + import os + + os.rmdir(temp_dir) except OSError: print("rmdir OSError") diff --git a/tests/extmod/vfs_userfs.py b/tests/extmod/vfs_userfs.py index 570b8335341..518373c70a9 100644 --- a/tests/extmod/vfs_userfs.py +++ b/tests/extmod/vfs_userfs.py @@ -1,21 +1,21 @@ # test VFS functionality with a user-defined filesystem -# also tests parts of uio.IOBase implementation +# also tests parts of io.IOBase implementation -import usys +import sys try: - import uio + import io - uio.IOBase - import uos + io.IOBase + import os - uos.mount + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit -class UserFile(uio.IOBase): +class UserFile(io.IOBase): def __init__(self, mode, data): assert isinstance(data, bytes) self.is_text = mode.find("b") == -1 @@ -69,16 +69,16 @@ def open(self, path, mode): "/usermod1.py": b"print('in usermod1')\nimport usermod2", "/usermod2.py": b"print('in usermod2')", } -uos.mount(UserFS(user_files), "/userfs") +os.mount(UserFS(user_files), "/userfs") # open and read a file f = open("/userfs/data.txt") print(f.read()) # import files from the user filesystem -usys.path.append("/userfs") +sys.path.append("/userfs") import usermod1 # unmount and undo path addition -uos.umount("/userfs") -usys.path.pop() +os.umount("/userfs") +sys.path.pop() diff --git a/tests/extmod/websocket_basic.py b/tests/extmod/websocket_basic.py index dabdb76be1e..133457784f6 100644 --- a/tests/extmod/websocket_basic.py +++ b/tests/extmod/websocket_basic.py @@ -1,7 +1,7 @@ try: - import uio - import uerrno - import uwebsocket + import io + import errno + import websocket except ImportError: print("SKIP") raise SystemExit @@ -9,14 +9,14 @@ # put raw data in the stream and do a websocket read def ws_read(msg, sz): - ws = uwebsocket.websocket(uio.BytesIO(msg)) + ws = websocket.websocket(io.BytesIO(msg)) return ws.read(sz) # do a websocket write and then return the raw data from the stream def ws_write(msg, sz): - s = uio.BytesIO() - ws = uwebsocket.websocket(s) + s = io.BytesIO() + ws = websocket.websocket(s) ws.write(msg) s.seek(0) return s.read(sz) @@ -38,8 +38,8 @@ def ws_write(msg, sz): print(ws_read(b"\x81\x84maskmask", 4)) # close control frame -s = uio.BytesIO(b"\x88\x00") # FRAME_CLOSE -ws = uwebsocket.websocket(s) +s = io.BytesIO(b"\x88\x00") # FRAME_CLOSE +ws = websocket.websocket(s) print(ws.read(1)) s.seek(2) print(s.read(4)) @@ -49,15 +49,15 @@ def ws_write(msg, sz): print(ws_read(b"\x8a\x00\x81\x04pong", 4)) # FRAME_PONG # close method -ws = uwebsocket.websocket(uio.BytesIO()) +ws = websocket.websocket(io.BytesIO()) ws.close() # ioctl -ws = uwebsocket.websocket(uio.BytesIO()) +ws = websocket.websocket(io.BytesIO()) print(ws.ioctl(8)) # GET_DATA_OPTS print(ws.ioctl(9, 2)) # SET_DATA_OPTS print(ws.ioctl(9)) try: ws.ioctl(-1) except OSError as e: - print("ioctl: EINVAL:", e.errno == uerrno.EINVAL) + print("ioctl: EINVAL:", e.errno == errno.EINVAL) diff --git a/tests/extmod/uzlib_decompio.py b/tests/extmod/zlib_decompio.py similarity index 93% rename from tests/extmod/uzlib_decompio.py rename to tests/extmod/zlib_decompio.py index fae901aad0a..9abbad43c60 100644 --- a/tests/extmod/uzlib_decompio.py +++ b/tests/extmod/zlib_decompio.py @@ -1,6 +1,6 @@ try: - import uzlib as zlib - import uio as io + import zlib + import io except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/uzlib_decompio.py.exp b/tests/extmod/zlib_decompio.py.exp similarity index 100% rename from tests/extmod/uzlib_decompio.py.exp rename to tests/extmod/zlib_decompio.py.exp diff --git a/tests/extmod/uzlib_decompio_gz.py b/tests/extmod/zlib_decompio_gz.py similarity index 97% rename from tests/extmod/uzlib_decompio_gz.py rename to tests/extmod/zlib_decompio_gz.py index 1bc8ba885ba..1407459304d 100644 --- a/tests/extmod/uzlib_decompio_gz.py +++ b/tests/extmod/zlib_decompio_gz.py @@ -1,6 +1,6 @@ try: - import uzlib as zlib - import uio as io + import zlib + import io except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/uzlib_decompio_gz.py.exp b/tests/extmod/zlib_decompio_gz.py.exp similarity index 100% rename from tests/extmod/uzlib_decompio_gz.py.exp rename to tests/extmod/zlib_decompio_gz.py.exp diff --git a/tests/extmod/uzlib_decompress.py b/tests/extmod/zlib_decompress.py similarity index 94% rename from tests/extmod/uzlib_decompress.py rename to tests/extmod/zlib_decompress.py index 8d4a9640b47..b72ee96ea88 100644 --- a/tests/extmod/uzlib_decompress.py +++ b/tests/extmod/zlib_decompress.py @@ -1,11 +1,8 @@ try: import zlib except ImportError: - try: - import uzlib as zlib - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit PATTERNS = [ # Packed results produced by CPy's zlib.compress() diff --git a/tests/feature_check/byteorder.py b/tests/feature_check/byteorder.py index 509bd8b1b51..c82a41a24b1 100644 --- a/tests/feature_check/byteorder.py +++ b/tests/feature_check/byteorder.py @@ -1,6 +1,3 @@ -try: - import usys as sys -except ImportError: - import sys +import sys print(sys.byteorder) diff --git a/tests/feature_check/uio_module.py b/tests/feature_check/io_module.py similarity index 56% rename from tests/feature_check/uio_module.py rename to tests/feature_check/io_module.py index bad8d7c95be..9094e605316 100644 --- a/tests/feature_check/uio_module.py +++ b/tests/feature_check/io_module.py @@ -1,6 +1,6 @@ try: - import uio + import io - print("uio") + print("io") except ImportError: print("no") diff --git a/tests/feature_check/uio_module.py.exp b/tests/feature_check/io_module.py.exp similarity index 100% rename from tests/feature_check/uio_module.py.exp rename to tests/feature_check/io_module.py.exp diff --git a/tests/float/array_construct.py b/tests/float/array_construct.py index f6a3a9dc9d4..6b5c996312d 100644 --- a/tests/float/array_construct.py +++ b/tests/float/array_construct.py @@ -1,13 +1,10 @@ # test construction of array from array with float type try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(array("f", array("h", [1, 2]))) print(array("d", array("f", [1, 2]))) diff --git a/tests/float/bytearray_construct_endian.py b/tests/float/bytearray_construct_endian.py index 47f2b793c06..a971d706e29 100644 --- a/tests/float/bytearray_construct_endian.py +++ b/tests/float/bytearray_construct_endian.py @@ -1,12 +1,9 @@ # test construction of bytearray from array with float type try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(bytearray(array("f", [1, 2.5]))) diff --git a/tests/float/bytes_construct_endian.py b/tests/float/bytes_construct_endian.py index 4e15acc8bc7..4dbcf390ea0 100644 --- a/tests/float/bytes_construct_endian.py +++ b/tests/float/bytes_construct_endian.py @@ -1,12 +1,9 @@ # test construction of bytes from array with float type try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(bytes(array("f", [1, 2.5]))) diff --git a/tests/float/float2int_doubleprec_intbig.py b/tests/float/float2int_doubleprec_intbig.py index adc76d4aeb2..402966cace2 100644 --- a/tests/float/float2int_doubleprec_intbig.py +++ b/tests/float/float2int_doubleprec_intbig.py @@ -1,11 +1,7 @@ # check cases converting float to int, requiring double precision float -try: - import ustruct as struct - import usys as sys -except: - import struct - import sys +import struct +import sys maxsize_bits = 0 maxsize = sys.maxsize diff --git a/tests/float/float2int_fp30_intbig.py b/tests/float/float2int_fp30_intbig.py index 4e3c1fa217b..1b22fe9646f 100644 --- a/tests/float/float2int_fp30_intbig.py +++ b/tests/float/float2int_fp30_intbig.py @@ -1,11 +1,7 @@ # check cases converting float to int, relying only on single precision float -try: - import ustruct as struct - import usys as sys -except: - import struct - import sys +import struct +import sys maxsize_bits = 0 maxsize = sys.maxsize diff --git a/tests/float/float2int_intbig.py b/tests/float/float2int_intbig.py index 739f98f804d..d047f247f27 100644 --- a/tests/float/float2int_intbig.py +++ b/tests/float/float2int_intbig.py @@ -1,11 +1,7 @@ # check cases converting float to int, relying only on single precision float -try: - import ustruct as struct - import usys as sys -except: - import struct - import sys +import struct +import sys maxsize_bits = 0 maxsize = sys.maxsize diff --git a/tests/float/float_array.py b/tests/float/float_array.py index 219b6b86aef..3d128da8381 100644 --- a/tests/float/float_array.py +++ b/tests/float/float_array.py @@ -1,11 +1,8 @@ try: - from uarray import array + from array import array except ImportError: - try: - from array import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def test(a): diff --git a/tests/float/float_struct.py b/tests/float/float_struct.py index 18893af0e0a..47fe4050180 100644 --- a/tests/float/float_struct.py +++ b/tests/float/float_struct.py @@ -1,9 +1,6 @@ # test struct package with floats try: - try: - import ustruct as struct - except: - import struct + import struct except ImportError: print("SKIP") raise SystemExit diff --git a/tests/import/builtin_ext.py b/tests/import/builtin_ext.py index dd8f95cbc13..87465f1d593 100644 --- a/tests/import/builtin_ext.py +++ b/tests/import/builtin_ext.py @@ -1,3 +1,4 @@ +# Verify that sys is a builtin. import sys print(sys, hasattr(sys, "__file__")) @@ -7,6 +8,8 @@ # All three should only get builtins, despite sys.py, usys.py, and # micropython.py being in the path. +# usys isn't extensible, but has a special-cased alias for backwards +# compatibility. import micropython print(micropython, hasattr(micropython, "__file__")) @@ -31,6 +34,7 @@ import uos print(uos, hasattr(uos, "__file__"), hasattr(uos, "extra")) + import utime print(utime, hasattr(utime, "__file__"), hasattr(utime, "extra")) diff --git a/tests/import/builtin_ext.py.exp b/tests/import/builtin_ext.py.exp index 08496e14b71..e09af2843af 100644 --- a/tests/import/builtin_ext.py.exp +++ b/tests/import/builtin_ext.py.exp @@ -6,5 +6,5 @@ os from filesystem True / 1 time from filesystem True 1 - False False - False False + False False + False False diff --git a/tests/import/ext/time.py b/tests/import/ext/time.py index 6f2d4a42c03..6b460b42355 100644 --- a/tests/import/ext/time.py +++ b/tests/import/ext/time.py @@ -4,11 +4,11 @@ # import. import sys -_path = sys.path[:] -sys.path.clear() +_path = sys.path +sys.path = () from time import * -sys.path.extend(_path) +sys.path = _path del _path extra = 1 diff --git a/tests/inlineasm/asmfpldrstr.py b/tests/inlineasm/asmfpldrstr.py index 96cd0c23eb5..c65f8a798b9 100644 --- a/tests/inlineasm/asmfpldrstr.py +++ b/tests/inlineasm/asmfpldrstr.py @@ -1,4 +1,4 @@ -import uarray as array +import array @micropython.asm_thumb # test vldr, vstr diff --git a/tests/inlineasm/asmsum.py b/tests/inlineasm/asmsum.py index 208709a25f7..51613ef6ac5 100644 --- a/tests/inlineasm/asmsum.py +++ b/tests/inlineasm/asmsum.py @@ -46,7 +46,7 @@ def asm_sum_bytes(r0, r1): mov(r0, r2) -import uarray as array +import array b = array.array("l", (100, 200, 300, 400)) n = asm_sum_words(len(b), b) diff --git a/tests/internal_bench/var-8-namedtuple-1st.py b/tests/internal_bench/var-8-namedtuple-1st.py index 1a6daa6cddc..e3a2fa19cd3 100644 --- a/tests/internal_bench/var-8-namedtuple-1st.py +++ b/tests/internal_bench/var-8-namedtuple-1st.py @@ -1,5 +1,5 @@ import bench -from ucollections import namedtuple +from collections import namedtuple T = namedtuple("Tup", ["num", "bar"]) diff --git a/tests/internal_bench/var-8.1-namedtuple-5th.py b/tests/internal_bench/var-8.1-namedtuple-5th.py index 568ece80671..3e521217466 100644 --- a/tests/internal_bench/var-8.1-namedtuple-5th.py +++ b/tests/internal_bench/var-8.1-namedtuple-5th.py @@ -1,5 +1,5 @@ import bench -from ucollections import namedtuple +from collections import namedtuple T = namedtuple("Tup", ["foo1", "foo2", "foo3", "foo4", "num"]) diff --git a/tests/io/argv.py b/tests/io/argv.py index 834292504d0..53254da1190 100644 --- a/tests/io/argv.py +++ b/tests/io/argv.py @@ -1,6 +1,3 @@ -try: - import usys as sys -except ImportError: - import sys +import sys print(sys.argv) diff --git a/tests/io/builtin_print_file.py b/tests/io/builtin_print_file.py index e5c20b64e4b..822356a6cc3 100644 --- a/tests/io/builtin_print_file.py +++ b/tests/io/builtin_print_file.py @@ -1,9 +1,6 @@ # test builtin print function, using file= argument -try: - import usys as sys -except ImportError: - import sys +import sys try: sys.stdout diff --git a/tests/io/file_stdio.py b/tests/io/file_stdio.py index 6c08f35d787..cbdb070163c 100644 --- a/tests/io/file_stdio.py +++ b/tests/io/file_stdio.py @@ -1,7 +1,4 @@ -try: - import usys as sys -except ImportError: - import sys +import sys print(sys.stdin.fileno()) print(sys.stdout.fileno()) diff --git a/tests/io/open_append.py b/tests/io/open_append.py index 49cdd094b3d..80a9422d815 100644 --- a/tests/io/open_append.py +++ b/tests/io/open_append.py @@ -1,7 +1,4 @@ -try: - import uos as os -except ImportError: - import os +import os if not hasattr(os, "remove"): print("SKIP") diff --git a/tests/io/open_plus.py b/tests/io/open_plus.py index 3cb2330eed4..5199861a4e3 100644 --- a/tests/io/open_plus.py +++ b/tests/io/open_plus.py @@ -1,7 +1,4 @@ -try: - import uos as os -except ImportError: - import os +import os if not hasattr(os, "remove"): print("SKIP") diff --git a/tests/micropython/builtin_execfile.py b/tests/micropython/builtin_execfile.py index 8a8ce79f784..5a26ccf0ad3 100644 --- a/tests/micropython/builtin_execfile.py +++ b/tests/micropython/builtin_execfile.py @@ -1,17 +1,17 @@ # Test builtin execfile function using VFS. try: - import uio, uos + import io, os execfile - uio.IOBase - uos.mount + io.IOBase + os.mount except (ImportError, NameError, AttributeError): print("SKIP") raise SystemExit -class File(uio.IOBase): +class File(io.IOBase): def __init__(self, data): self.data = data self.off = 0 @@ -44,21 +44,25 @@ def open(self, file, mode): # First umount any existing mount points the target may have. try: - uos.umount("/") + import io, os + + os.umount("/") except OSError: pass -for path in uos.listdir("/"): - uos.umount("/" + path) +for path in os.listdir("/"): + os.umount("/" + path) # Create and mount the VFS object. files = { "/test.py": "print(123)", } fs = Filesystem(files) -uos.mount(fs, "/test_mnt") +os.mount(fs, "/test_mnt") # Test execfile with a file that doesn't exist. try: + import io, os + execfile("/test_mnt/noexist.py") except OSError: print("OSError") @@ -67,4 +71,4 @@ def open(self, file, mode): execfile("/test_mnt/test.py") # Unmount the VFS object. -uos.umount(fs) +os.umount(fs) diff --git a/tests/micropython/emg_exc.py b/tests/micropython/emg_exc.py index b8df94b071a..9a09956c861 100644 --- a/tests/micropython/emg_exc.py +++ b/tests/micropython/emg_exc.py @@ -1,10 +1,10 @@ # test that emergency exceptions work import micropython -import usys +import sys try: - import uio + import io except ImportError: print("SKIP") raise SystemExit @@ -25,8 +25,8 @@ def f(): micropython.heap_unlock() # print the exception - buf = uio.StringIO() - usys.print_exception(exc, buf) + buf = io.StringIO() + sys.print_exception(exc, buf) for l in buf.getvalue().split("\n"): if l.startswith(" File "): print(l.split('"')[2]) diff --git a/tests/micropython/heapalloc_bytesio.py b/tests/micropython/heapalloc_bytesio.py index 4aae2abf063..0ac8c92555a 100644 --- a/tests/micropython/heapalloc_bytesio.py +++ b/tests/micropython/heapalloc_bytesio.py @@ -1,5 +1,5 @@ try: - import uio + import io except ImportError: print("SKIP") raise SystemExit @@ -7,7 +7,7 @@ import micropython data = b"1234" * 16 -buf = uio.BytesIO(64) +buf = io.BytesIO(64) micropython.heap_lock() diff --git a/tests/micropython/heapalloc_bytesio2.py b/tests/micropython/heapalloc_bytesio2.py index 3b9f141270d..05c384a516d 100644 --- a/tests/micropython/heapalloc_bytesio2.py +++ b/tests/micropython/heapalloc_bytesio2.py @@ -1,7 +1,7 @@ # Creating BytesIO from immutable object should not immediately # copy its content. try: - import uio + import io import micropython micropython.mem_total @@ -14,7 +14,7 @@ before = micropython.mem_total() -buf = uio.BytesIO(data) +buf = io.BytesIO(data) after = micropython.mem_total() diff --git a/tests/micropython/heapalloc_iter.py b/tests/micropython/heapalloc_iter.py index 18f5322ee15..bd1ba4db79f 100644 --- a/tests/micropython/heapalloc_iter.py +++ b/tests/micropython/heapalloc_iter.py @@ -5,13 +5,10 @@ print("SKIP") raise SystemExit try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: from micropython import heap_lock, heap_unlock diff --git a/tests/micropython/heapalloc_traceback.py b/tests/micropython/heapalloc_traceback.py index 09a2ad2c14d..4c5f99afeeb 100644 --- a/tests/micropython/heapalloc_traceback.py +++ b/tests/micropython/heapalloc_traceback.py @@ -1,10 +1,10 @@ # test that we can generate a traceback without allocating import micropython -import usys +import sys try: - import uio + import io except ImportError: print("SKIP") raise SystemExit @@ -32,8 +32,8 @@ def test(): test() # print the exception that was raised -buf = uio.StringIO() -usys.print_exception(global_exc, buf) +buf = io.StringIO() +sys.print_exception(global_exc, buf) for l in buf.getvalue().split("\n"): # uPy on pyboard prints as file, so remove filename. if l.startswith(" File "): diff --git a/tests/micropython/import_mpy_invalid.py b/tests/micropython/import_mpy_invalid.py index b02312a7a8d..36db102e9d6 100644 --- a/tests/micropython/import_mpy_invalid.py +++ b/tests/micropython/import_mpy_invalid.py @@ -1,16 +1,16 @@ # test importing of invalid .mpy files try: - import usys, uio, uos + import sys, io, os - uio.IOBase - uos.mount + io.IOBase + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit -class UserFile(uio.IOBase): +class UserFile(io.IOBase): def __init__(self, data): self.data = memoryview(data) self.pos = 0 @@ -52,8 +52,8 @@ def open(self, path, mode): } # create and mount a user filesystem -uos.mount(UserFS(user_files), "/userfs") -usys.path.append("/userfs") +os.mount(UserFS(user_files), "/userfs") +sys.path.append("/userfs") # import .mpy files from the user filesystem for i in range(len(user_files)): @@ -64,5 +64,5 @@ def open(self, path, mode): print(mod, "ValueError", er) # unmount and undo path addition -uos.umount("/userfs") -usys.path.pop() +os.umount("/userfs") +sys.path.pop() diff --git a/tests/micropython/import_mpy_native.py b/tests/micropython/import_mpy_native.py index 73e20694cc2..da20746b225 100644 --- a/tests/micropython/import_mpy_native.py +++ b/tests/micropython/import_mpy_native.py @@ -1,23 +1,23 @@ # test importing of .mpy files with native code try: - import usys, uio, uos + import sys, io, os - usys.implementation._mpy - uio.IOBase - uos.mount + sys.implementation._mpy + io.IOBase + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit -mpy_arch = usys.implementation._mpy >> 8 +mpy_arch = sys.implementation._mpy >> 8 if mpy_arch >> 2 == 0: # This system does not support .mpy files containing native code print("SKIP") raise SystemExit -class UserFile(uio.IOBase): +class UserFile(io.IOBase): def __init__(self, data): self.data = memoryview(data) self.pos = 0 @@ -110,8 +110,8 @@ def open(self, path, mode): # fmt: on # create and mount a user filesystem -uos.mount(UserFS(user_files), "/userfs") -usys.path.append("/userfs") +os.mount(UserFS(user_files), "/userfs") +sys.path.append("/userfs") # import .mpy files from the user filesystem for i in range(len(user_files)): @@ -123,5 +123,5 @@ def open(self, path, mode): print(mod, "ValueError", er) # unmount and undo path addition -uos.umount("/userfs") -usys.path.pop() +os.umount("/userfs") +sys.path.pop() diff --git a/tests/micropython/import_mpy_native_gc.py b/tests/micropython/import_mpy_native_gc.py index e18720fb314..5a3855dc7d2 100644 --- a/tests/micropython/import_mpy_native_gc.py +++ b/tests/micropython/import_mpy_native_gc.py @@ -1,17 +1,17 @@ # Test that native code loaded from a .mpy file is retained after a GC. try: - import gc, sys, uio, uos + import gc, sys, io, os sys.implementation._mpy - uio.IOBase - uos.mount + io.IOBase + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit -class UserFile(uio.IOBase): +class UserFile(io.IOBase): def __init__(self, data): self.data = memoryview(data) self.pos = 0 @@ -68,7 +68,7 @@ def open(self, path, mode): user_files = {"/features0.mpy": features0_file_contents[sys_implementation_mpy]} # Create and mount a user filesystem. -uos.mount(UserFS(user_files), "/userfs") +os.mount(UserFS(user_files), "/userfs") sys.path.append("/userfs") # Import the native function. @@ -89,5 +89,5 @@ def open(self, path, mode): print(factorial(10)) # Unmount and undo path addition. -uos.umount("/userfs") +os.umount("/userfs") sys.path.pop() diff --git a/tests/micropython/opt_level_lineno.py b/tests/micropython/opt_level_lineno.py index 1cbf2fb1a85..d8253e54b41 100644 --- a/tests/micropython/opt_level_lineno.py +++ b/tests/micropython/opt_level_lineno.py @@ -3,4 +3,4 @@ # check that level 3 doesn't store line numbers # the expected output is that any line is printed as "line 1" micropython.opt_level(3) -exec("try:\n xyz\nexcept NameError as er:\n import usys\n usys.print_exception(er)") +exec("try:\n xyz\nexcept NameError as er:\n import sys\n sys.print_exception(er)") diff --git a/tests/micropython/viper_misc_intbig.py b/tests/micropython/viper_misc_intbig.py index ac09f578572..91673f2c108 100644 --- a/tests/micropython/viper_misc_intbig.py +++ b/tests/micropython/viper_misc_intbig.py @@ -7,6 +7,6 @@ def viper_uint() -> uint: return uint(-1) -import usys +import sys -print(viper_uint() == (usys.maxsize << 1 | 1)) +print(viper_uint() == (sys.maxsize << 1 | 1)) diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py index cc63185b5d2..da90f90ac3e 100644 --- a/tests/misc/non_compliant.py +++ b/tests/misc/non_compliant.py @@ -1,8 +1,8 @@ # tests for things that are not implemented, or have non-compliant behaviour try: - import uarray as array - import ustruct + import array + import struct except ImportError: print("SKIP") raise SystemExit @@ -106,10 +106,10 @@ print("NotImplementedError") # struct pack with too many args, not checked by uPy -print(ustruct.pack("bb", 1, 2, 3)) +print(struct.pack("bb", 1, 2, 3)) # struct pack with too few args, not checked by uPy -print(ustruct.pack("bb", 1)) +print(struct.pack("bb", 1)) # array slice assignment with unsupported RHS try: diff --git a/tests/misc/print_exception.py b/tests/misc/print_exception.py index 06f4023349a..1d196d6ab16 100644 --- a/tests/misc/print_exception.py +++ b/tests/misc/print_exception.py @@ -1,10 +1,6 @@ try: - try: - import uio as io - import usys as sys - except ImportError: - import io - import sys + import io + import sys except ImportError: print("SKIP") raise SystemExit diff --git a/tests/misc/sys_atexit.py b/tests/misc/sys_atexit.py index 141b24cc9f6..e9c5693f975 100644 --- a/tests/misc/sys_atexit.py +++ b/tests/misc/sys_atexit.py @@ -1,9 +1,9 @@ # test sys.atexit() function -import usys +import sys try: - usys.atexit + sys.atexit except AttributeError: print("SKIP") raise SystemExit @@ -15,7 +15,7 @@ def do_at_exit(): print("done at exit:", some_var) -usys.atexit(do_at_exit) +sys.atexit(do_at_exit) some_var = "ok" print("done before exit") diff --git a/tests/misc/sys_exc_info.py b/tests/misc/sys_exc_info.py index 3a8c4a6c8d3..d7e8a2d943b 100644 --- a/tests/misc/sys_exc_info.py +++ b/tests/misc/sys_exc_info.py @@ -1,7 +1,4 @@ -try: - import usys as sys -except ImportError: - import sys +import sys try: sys.exc_info diff --git a/tests/multi_net/ssl_cert_rsa.py b/tests/multi_net/ssl_cert_rsa.py index 7c718ee40a5..872855edbaf 100644 --- a/tests/multi_net/ssl_cert_rsa.py +++ b/tests/multi_net/ssl_cert_rsa.py @@ -2,7 +2,7 @@ # This test won't run under CPython because CPython doesn't have key/cert try: - import ubinascii as binascii, usocket as socket, ussl as ssl + import binascii, socket, ssl except ImportError: print("SKIP") raise SystemExit diff --git a/tests/multi_net/ssl_data.py b/tests/multi_net/ssl_data.py index aef85b83ab3..a21c8c65893 100644 --- a/tests/multi_net/ssl_data.py +++ b/tests/multi_net/ssl_data.py @@ -2,7 +2,7 @@ # This test won't run under CPython because it requires key/cert try: - import ubinascii as binascii, usocket as socket, ussl as ssl + import binascii, socket, ssl except ImportError: print("SKIP") raise SystemExit diff --git a/tests/multi_net/uasyncio_tcp_readinto.py b/tests/multi_net/uasyncio_tcp_readinto.py index 631997652aa..647c06b8aaa 100644 --- a/tests/multi_net/uasyncio_tcp_readinto.py +++ b/tests/multi_net/uasyncio_tcp_readinto.py @@ -10,13 +10,10 @@ raise SystemExit try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit PORT = 8000 diff --git a/tests/net_hosted/accept_nonblock.py b/tests/net_hosted/accept_nonblock.py index d17e287498c..30d2033e652 100644 --- a/tests/net_hosted/accept_nonblock.py +++ b/tests/net_hosted/accept_nonblock.py @@ -1,9 +1,6 @@ # test that socket.accept() on a non-blocking socket raises EAGAIN -try: - import usocket as socket -except: - import socket +import socket s = socket.socket() s.bind(socket.getaddrinfo("127.0.0.1", 8123)[0][-1]) diff --git a/tests/net_hosted/accept_timeout.py b/tests/net_hosted/accept_timeout.py index 734fe217cad..865d2aad26f 100644 --- a/tests/net_hosted/accept_timeout.py +++ b/tests/net_hosted/accept_timeout.py @@ -1,9 +1,6 @@ # test that socket.accept() on a socket with timeout raises ETIMEDOUT -try: - import uerrno as errno, usocket as socket -except: - import errno, socket +import errno, socket try: socket.socket.settimeout diff --git a/tests/net_hosted/connect_nonblock.py b/tests/net_hosted/connect_nonblock.py index 4b8055c1615..781f1a4ee2c 100644 --- a/tests/net_hosted/connect_nonblock.py +++ b/tests/net_hosted/connect_nonblock.py @@ -1,10 +1,6 @@ # test that socket.connect() on a non-blocking socket raises EINPROGRESS -try: - import usocket as socket - import uerrno as errno -except: - import socket, errno +import socket, errno def test(peer_addr): diff --git a/tests/net_hosted/connect_nonblock_xfer.py b/tests/net_hosted/connect_nonblock_xfer.py index 1a0b2422765..e669a5766c4 100644 --- a/tests/net_hosted/connect_nonblock_xfer.py +++ b/tests/net_hosted/connect_nonblock_xfer.py @@ -1,11 +1,8 @@ # test that socket.connect() on a non-blocking socket raises EINPROGRESS # and that an immediate write/send/read/recv does the right thing -try: - import sys, time - import uerrno as errno, usocket as socket, ussl as ssl -except: - import socket, errno, ssl +import sys, time, socket, errno, ssl + isMP = sys.implementation.name == "micropython" diff --git a/tests/net_hosted/connect_poll.py b/tests/net_hosted/connect_poll.py index b2739e36e9d..a3232bd334e 100644 --- a/tests/net_hosted/connect_poll.py +++ b/tests/net_hosted/connect_poll.py @@ -1,9 +1,6 @@ # test that socket.connect() has correct polling behaviour before, during and after -try: - import usocket as socket, uselect as select -except: - import socket, select +import socket, select def test(peer_addr): diff --git a/tests/net_hosted/ssl_getpeercert.py b/tests/net_hosted/ssl_getpeercert.py index dee5fcfd899..0df895a654b 100644 --- a/tests/net_hosted/ssl_getpeercert.py +++ b/tests/net_hosted/ssl_getpeercert.py @@ -1,11 +1,7 @@ # test ssl.getpeercert() method -try: - import usocket as socket - import ussl as ssl -except: - import socket - import ssl +import socket +import ssl def test(peer_addr): diff --git a/tests/net_inet/getaddrinfo.py b/tests/net_inet/getaddrinfo.py index 765723ae73f..e26060ad212 100644 --- a/tests/net_inet/getaddrinfo.py +++ b/tests/net_inet/getaddrinfo.py @@ -1,7 +1,4 @@ -try: - import usocket as socket, sys -except: - import socket, sys +import socket, sys def test_non_existent(): diff --git a/tests/net_inet/ssl_cert.py b/tests/net_inet/ssl_cert.py index d2d437e381b..d6e0aec8897 100644 --- a/tests/net_inet/ssl_cert.py +++ b/tests/net_inet/ssl_cert.py @@ -1,6 +1,6 @@ -import ubinascii as binascii -import usocket as socket -import ussl as ssl +import binascii +import socket +import ssl # This certificate was obtained from micropython.org using openssl: diff --git a/tests/net_inet/ssl_errors.py b/tests/net_inet/ssl_errors.py index ece1f6e253b..65f3637e9e2 100644 --- a/tests/net_inet/ssl_errors.py +++ b/tests/net_inet/ssl_errors.py @@ -1,12 +1,7 @@ # test that socket.connect() on a non-blocking socket raises EINPROGRESS # and that an immediate write/send/read/recv does the right thing -import sys - -try: - import uerrno as errno, usocket as socket, ussl as ssl -except: - import errno, socket, ssl +import sys, errno, socket, ssl def test(addr, hostname, block=True): diff --git a/tests/net_inet/test_tls_nonblock.py b/tests/net_inet/test_tls_nonblock.py index b4f2ef4ed27..6378280a71d 100644 --- a/tests/net_inet/test_tls_nonblock.py +++ b/tests/net_inet/test_tls_nonblock.py @@ -1,7 +1,4 @@ -try: - import usocket as socket, ussl as ssl, uerrno as errno, sys -except: - import socket, ssl, errno, sys, time, select +import socket, ssl, errno, sys, time, select def test_one(site, opts): diff --git a/tests/net_inet/test_tls_sites.py b/tests/net_inet/test_tls_sites.py index fabe4b43c9c..f9a3dc86d2f 100644 --- a/tests/net_inet/test_tls_sites.py +++ b/tests/net_inet/test_tls_sites.py @@ -1,21 +1,16 @@ -try: - import usocket as _socket -except: - import _socket -try: - import ussl as ssl -except: - import ssl - - # CPython only supports server_hostname with SSLContext +import socket +import ssl + +# CPython only supports server_hostname with SSLContext +if hasattr(ssl, "SSLContext"): ssl = ssl.SSLContext() def test_one(site, opts): - ai = _socket.getaddrinfo(site, 443) + ai = socket.getaddrinfo(site, 443) addr = ai[0][-1] - s = _socket.socket() + s = socket.socket() try: s.connect(addr) diff --git a/tests/net_inet/tls_num_errors.py b/tests/net_inet/tls_num_errors.py index dd7f714e6ef..34aa2bb4551 100644 --- a/tests/net_inet/tls_num_errors.py +++ b/tests/net_inet/tls_num_errors.py @@ -1,9 +1,7 @@ # test that modtls produces a numerical error message when out of heap -try: - import usocket as socket, ussl as ssl, sys -except: - import socket, ssl, sys +import socket, ssl, sys + try: from micropython import alloc_emergency_exception_buf, heap_lock, heap_unlock except: diff --git a/tests/net_inet/tls_text_errors.py b/tests/net_inet/tls_text_errors.py index 9e8ccfaf9ec..498593bba22 100644 --- a/tests/net_inet/tls_text_errors.py +++ b/tests/net_inet/tls_text_errors.py @@ -1,9 +1,6 @@ # test that modtls produces a text error message -try: - import usocket as socket, ussl as ssl, sys -except: - import socket, ssl, sys +import socket, ssl, sys def test(addr): diff --git a/tests/perf_bench/benchrun.py b/tests/perf_bench/benchrun.py index ed43297d15f..4029c8ac8aa 100644 --- a/tests/perf_bench/benchrun.py +++ b/tests/perf_bench/benchrun.py @@ -1,10 +1,10 @@ def bm_run(N, M): try: - from utime import ticks_us, ticks_diff + from time import ticks_us, ticks_diff except ImportError: - import time + from time import perf_counter - ticks_us = lambda: int(time.perf_counter() * 1000000) + ticks_us = lambda: int(perf_counter() * 1000000) ticks_diff = lambda a, b: a - b # Pick sensible parameters given N, M diff --git a/tests/perf_bench/bm_hexiom.py b/tests/perf_bench/bm_hexiom.py index 84eda9a9096..e36fc234cd7 100644 --- a/tests/perf_bench/bm_hexiom.py +++ b/tests/perf_bench/bm_hexiom.py @@ -632,10 +632,7 @@ def solve_file(file, strategy, order, output): def bm_setup(params): - try: - import uio as io - except ImportError: - import io + import io loops, level, order, strategy = params diff --git a/tests/perf_bench/core_import_mpy_multi.py b/tests/perf_bench/core_import_mpy_multi.py index 99c4721d29d..ce68306678b 100644 --- a/tests/perf_bench/core_import_mpy_multi.py +++ b/tests/perf_bench/core_import_mpy_multi.py @@ -1,8 +1,8 @@ # Test performance of importing an .mpy file many times. -import usys, uio, uos +import sys, io, os -if not (hasattr(uio, "IOBase") and hasattr(uos, "mount")): +if not (hasattr(io, "IOBase") and hasattr(os, "mount")): print("SKIP") raise SystemExit @@ -26,7 +26,7 @@ def f(): file_data = b'M\x06\x00\x1f\x14\x03\x0etest.py\x00\x0f\x02A\x00\x02f\x00\x0cresult\x00/-5#\x82I\x81{\x81w\x82/\x81\x05\x81\x17Iom\x82\x13\x06arg\x00\x05\x1cthis will be a string object\x00\x06\x1bthis will be a bytes object\x00\n\x07\x05\x0bconst tuple\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\x81\\\x10\n\x01\x89\x07d`T2\x00\x10\x024\x02\x16\x022\x01\x16\x03"\x80{\x16\x04Qc\x02\x81d\x00\x08\x02(DD\x11\x05\x16\x06\x10\x02\x16\x072\x00\x16\x082\x01\x16\t2\x02\x16\nQc\x03`\x1a\x08\x08\x12\x13@\xb1\xb0\x18\x13Qc@\t\x08\t\x12` Qc@\t\x08\n\x12``Qc\x82@ \x0e\x03\x80\x08+)##\x12\x0b\x12\x0c\x12\r\x12\x0e*\x04Y\x12\x0f\x12\x10\x12\x11*\x03Y#\x00\xc0#\x01\xc0#\x02\xc0Qc' -class File(uio.IOBase): +class File(io.IOBase): def __init__(self): self.off = 0 @@ -57,14 +57,14 @@ def open(self, path, mode): def mount(): - uos.mount(FS(), "/__remote") - uos.chdir("/__remote") + os.mount(FS(), "/__remote") + os.chdir("/__remote") def test(r): global result for _ in r: - usys.modules.clear() + sys.modules.clear() module = __import__("__injected") result = module.result diff --git a/tests/perf_bench/core_import_mpy_single.py b/tests/perf_bench/core_import_mpy_single.py index af3f4a29b25..1b411fc3fb6 100644 --- a/tests/perf_bench/core_import_mpy_single.py +++ b/tests/perf_bench/core_import_mpy_single.py @@ -2,9 +2,9 @@ # The first import of a module will intern strings that don't already exist, and # this test should be representative of what happens in a real application. -import uio, uos +import io, os -if not (hasattr(uio, "IOBase") and hasattr(uos, "mount")): +if not (hasattr(io, "IOBase") and hasattr(os, "mount")): print("SKIP") raise SystemExit @@ -81,7 +81,7 @@ def f1(): file_data = b"M\x06\x00\x1f\x81=\x1e\x0etest.py\x00\x0f\x04A0\x00\x04A1\x00\x04f0\x00\x04f1\x00\x0cresult\x00/-5\x04a0\x00\x04a1\x00\x04a2\x00\x04a3\x00\x13\x15\x17\x19\x1b\x1d\x1f!#%')+1379;=?ACEGIKMOQSUWY[]_acegikmoqsuwy{}\x7f\x81\x01\x81\x03\x81\x05\x81\x07\x81\t\x81\x0b\x81\r\x81\x0f\x81\x11\x81\x13\x81\x15\x81\x17\x81\x19\x81\x1b\x81\x1d\x81\x1f\x81!\x81#\x81%\x81'\x81)\x81+\x81-\x81/\x811\x813\x815\x817\x819\x81;\x81=\x81?\x81A\x81C\x81E\x81G\x81I\x81K\x81M\x81O\x81Q\x81S\x81U\x81W\x81Y\x81[\x81]\x81_\x81a\x81c\x81e\x81g\x81i\x81k\x81m\x81o\x81q\x81s\x81u\x81w\x81y\x81{\x81}\x81\x7f\x82\x01\x82\x03\x82\x05\x82\x07\x82\t\x82\x0b\x82\r\x82\x0f\x82\x11\x82\x13\x82\x15\x82\x17\x82\x19\x82\x1b\x82\x1d\x82\x1f\x82!\x82#\x82%\x82'\x82)\x82+\x82-\x82/\x821\x823\x825\x827\x829\x82;\x82=\x82?\x82A\x82E\x82G\x82I\x82K\nname0\x00\nname1\x00\nname2\x00\nname3\x00\nname4\x00\nname5\x00\nname6\x00\nname7\x00\nname8\x00\nname9\x00$quite_a_long_name0\x00$quite_a_long_name1\x00$quite_a_long_name2\x00$quite_a_long_name3\x00$quite_a_long_name4\x00$quite_a_long_name5\x00$quite_a_long_name6\x00$quite_a_long_name7\x00$quite_a_long_name8\x00$quite_a_long_name9\x00&quite_a_long_name10\x00&quite_a_long_name11\x00\x05\x1ethis will be a string object 0\x00\x05\x1ethis will be a string object 1\x00\x05\x1ethis will be a string object 2\x00\x05\x1ethis will be a string object 3\x00\x05\x1ethis will be a string object 4\x00\x05\x1ethis will be a string object 5\x00\x05\x1ethis will be a string object 6\x00\x05\x1ethis will be a string object 7\x00\x05\x1ethis will be a string object 8\x00\x05\x1ethis will be a string object 9\x00\x06\x1dthis will be a bytes object 0\x00\x06\x1dthis will be a bytes object 1\x00\x06\x1dthis will be a bytes object 2\x00\x06\x1dthis will be a bytes object 3\x00\x06\x1dthis will be a bytes object 4\x00\x06\x1dthis will be a bytes object 5\x00\x06\x1dthis will be a bytes object 6\x00\x06\x1dthis will be a bytes object 7\x00\x06\x1dthis will be a bytes object 8\x00\x06\x1dthis will be a bytes object 9\x00\n\x07\x05\rconst tuple 0\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 1\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 2\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 3\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 4\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 5\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 6\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 7\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 8\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 9\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\x82d\x10\x12\x01i@i@\x84\x18\x84\x1fT2\x00\x10\x024\x02\x16\x02T2\x01\x10\x034\x02\x16\x032\x02\x16\x042\x03\x16\x05\"\x80{\x16\x06Qc\x04\x82\x0c\x00\n\x02($$$\x11\x07\x16\x08\x10\x02\x16\t2\x00\x16\n2\x01\x16\x0b2\x02\x16\x0c2\x03\x16\rQc\x04@\t\x08\n\x81\x0b Qc@\t\x08\x0b\x81\x0b@Qc@\t\x08\x0c\x81\x0b`QcH\t\n\r\x81\x0b` Qc\x82\x14\x00\x0c\x03h`$$$\x11\x07\x16\x08\x10\x03\x16\t2\x00\x16\n2\x01\x16\x0b2\x02\x16\x0c2\x03\x16\rQc\x04H\t\n\n\x81\x0b``QcH\t\n\x0b\x81\x0b\x80\x07QcH\t\n\x0c\x81\x0b\x80\x08QcH\t\n\r\x81\x0b\x80\tQc\xa08P:\x04\x80\x0b13///---997799<\x1f%\x1f\"\x1f%)\x1f\"//\x12\x0e\x12\x0f\x12\x10\x12\x11\x12\x12\x12\x13\x12\x14*\x07Y\x12\x15\x12\x16\x12\x17\x12\x18\x12\x19\x12\x1a\x12\x08\x12\x07*\x08Y\x12\x1b\x12\x1c\x12\t\x12\x1d\x12\x1e\x12\x1f*\x06Y\x12 \x12!\x12\"\x12#\x12$\x12%*\x06Y\x12&\x12'\x12(\x12)\x12*\x12+*\x06Y\x12,\x12-\x12.\x12/\x120*\x05Y\x121\x122\x123\x124\x125*\x05Y\x126\x127\x128\x129\x12:*\x05Y\x12;\x12<\x12=\x12>\x12?\x12@\x12A\x12B\x12C\x12D\x12E*\x0bY\x12F\x12G\x12H\x12I\x12J\x12K\x12L\x12M\x12N\x12O\x12P*\x0bY\x12Q\x12R\x12S\x12T\x12U\x12V\x12W\x12X\x12Y\x12Z*\nY\x12[\x12\\\x12]\x12^\x12_\x12`\x12a\x12b\x12c\x12d*\nY\x12e\x12f\x12g\x12h\x12i\x12j\x12k\x12l\x12m\x12n\x12o*\x0bY\x12p\x12q\x12r\x12s\x12t\x12u\x12v\x12w\x12x\x12y\x12z*\x0bY\x12{\x12|\x12}\x12~\x12\x7f\x12\x81\x00\x12\x81\x01\x12\x81\x02\x12\x81\x03\x12\x81\x04*\nY\x12\x81\x05\x12\x81\x06\x12\x81\x07\x12\x81\x08\x12\x81\t\x12\x81\n\x12\x81\x0b\x12\x81\x0c\x12\x81\r\x12\x81\x0e\x12\x81\x0f*\x0bY\x12\x81\x10\x12\x81\x11\x12\x81\x12\x12\x81\x13\x12\x81\x14\x12\x81\x15\x12\x81\x16\x12\x81\x17\x12\x81\x18\x12\x81\x19*\nY\x12\x81\x1a\x12\x81\x1b\x12\x81\x1c\x12\x81\x1d\x12\x81\x1e\x12\x81\x1f\x12\x81 \x12\x81!\x12\x81\"\x12\x81#\x12\x81$*\x0bY\x12\x81%\x12\x81&*\x02Y\x12\x81'\x12\x81(\x12\x81)\x12\x81*\x12\x81+\x12\x81,\x12\x81-\x12\x81.\x12\x81/\x12\x810*\nY\x12\x811\x12\x812\x12\x813\x12\x814*\x04Y\x12\x815\x12\x816\x12\x817\x12\x818*\x04Y\x12\x819\x12\x81:\x12\x81;\x12\x81<*\x04YQc\x87p\x08@\x05\x80###############################\x00\xc0#\x01\xc0#\x02\xc0#\x03\xc0#\x04\xc0#\x05\xc0#\x06\xc0#\x07\xc0#\x08\xc0#\t\xc0#\n\xc0#\x0b\xc0#\x0c\xc0#\r\xc0#\x0e\xc0#\x0f\xc0#\x10\xc0#\x11\xc0#\x12\xc0#\x13\xc0#\x14\xc0#\x15\xc0#\x16\xc0#\x17\xc0#\x18\xc0#\x19\xc0#\x1a\xc0#\x1b\xc0#\x1c\xc0#\x1d\xc0Qc" -class File(uio.IOBase): +class File(io.IOBase): def __init__(self): self.off = 0 @@ -112,8 +112,8 @@ def open(self, path, mode): def mount(): - uos.mount(FS(), "/__remote") - uos.chdir("/__remote") + os.mount(FS(), "/__remote") + os.chdir("/__remote") def test(): diff --git a/tests/renesas-ra/freq.py b/tests/renesas-ra/freq.py index 6ce1871f8c1..97fe946b72a 100644 --- a/tests/renesas-ra/freq.py +++ b/tests/renesas-ra/freq.py @@ -20,7 +20,7 @@ try: import machine -except: +except ImportError: print("machine module is not found") raise SystemExit diff --git a/tests/run-natmodtests.py b/tests/run-natmodtests.py index 16bb4692225..9fe970a6d09 100755 --- a/tests/run-natmodtests.py +++ b/tests/run-natmodtests.py @@ -22,16 +22,16 @@ TEST_MAPPINGS = { "btree": "btree/btree_$(ARCH).mpy", "framebuf": "framebuf/framebuf_$(ARCH).mpy", - "uheapq": "uheapq/uheapq_$(ARCH).mpy", - "urandom": "urandom/urandom_$(ARCH).mpy", - "ure": "ure/ure_$(ARCH).mpy", - "uzlib": "uzlib/uzlib_$(ARCH).mpy", + "heapq": "heapq/heapq_$(ARCH).mpy", + "random": "random/random_$(ARCH).mpy", + "re": "re/re_$(ARCH).mpy", + "zlib": "zlib/zlib_$(ARCH).mpy", } # Code to allow a target MicroPython to import an .mpy from RAM injected_import_hook_code = """\ -import usys, uos, uio -class __File(uio.IOBase): +import sys, os, io +class __File(io.IOBase): def __init__(self): self.off = 0 def ioctl(self, request, arg): @@ -52,9 +52,9 @@ def stat(self, path): raise OSError(-2) # ENOENT def open(self, path, mode): return __File() -uos.mount(__FS(), '/__remote') -uos.chdir('/__remote') -usys.modules['{}'] = __import__('__injected') +os.mount(__FS(), '/__remote') +os.chdir('/__remote') +sys.modules['{}'] = __import__('__injected') """ diff --git a/tests/run-tests-exp.py b/tests/run-tests-exp.py index 21b6645336f..bbb057f4ced 100644 --- a/tests/run-tests-exp.py +++ b/tests/run-tests-exp.py @@ -5,8 +5,8 @@ # This script is intended to be run by the same interpreter executable # which is to be tested, so should use minimal language functionality. # -import usys as sys -import uos as os +import sys +import os tests = ["basics", "micropython", "float", "import", "io", " misc", "unicode", "extmod", "unix"] diff --git a/tests/run-tests.py b/tests/run-tests.py index 498db8b4041..4964ff49fd0 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -56,8 +56,8 @@ def base_path(*p): # Code to allow a target MicroPython to import an .mpy from RAM injected_import_hook_code = """\ -import usys, uos, uio -class __File(uio.IOBase): +import sys, os, io +class __File(io.IOBase): def __init__(self): self.off = 0 def ioctl(self, request, arg): @@ -80,8 +80,8 @@ def stat(self, path): raise OSError(-2) # ENOENT def open(self, path, mode): return __File() -uos.mount(__FS(), '/__vfstest') -uos.chdir('/__vfstest') +os.mount(__FS(), '/__vfstest') +os.chdir('/__vfstest') __import__('__injected_test') """ @@ -455,9 +455,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): if output == b"TypeError\n": skip_revops = True - # Check if uio module exists, and skip such tests if it doesn't - output = run_feature_check(pyb, args, base_path, "uio_module.py") - if output != b"uio\n": + # Check if io module exists, and skip such tests if it doesn't + output = run_feature_check(pyb, args, base_path, "io_module.py") + if output != b"io\n": skip_io_module = True # Check if fstring feature is enabled, and skip such tests if it doesn't @@ -512,9 +512,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): skip_tests.add("extmod/uctypes_le_float.py") skip_tests.add("extmod/uctypes_native_float.py") skip_tests.add("extmod/uctypes_sizeof_float.py") - skip_tests.add("extmod/ujson_dumps_float.py") - skip_tests.add("extmod/ujson_loads_float.py") - skip_tests.add("extmod/urandom_extra_float.py") + skip_tests.add("extmod/json_dumps_float.py") + skip_tests.add("extmod/json_loads_float.py") + skip_tests.add("extmod/random_extra_float.py") skip_tests.add("misc/rge_sm.py") if upy_float_precision < 32: skip_tests.add( @@ -544,7 +544,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): if not has_coverage: skip_tests.add("cmdline/cmd_parsetree.py") skip_tests.add("cmdline/repl_sys_ps1_ps2.py") - skip_tests.add("extmod/ussl_poll.py") + skip_tests.add("extmod/ssl_poll.py") # Some tests shouldn't be run on a PC if args.target == "unix": @@ -568,9 +568,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): } ) # requires uctypes skip_tests.add("extmod/zlibd_decompress.py") # requires zlib - skip_tests.add("extmod/uheapq1.py") # uheapq not supported by WiPy - skip_tests.add("extmod/urandom_basic.py") # requires urandom - skip_tests.add("extmod/urandom_extra.py") # requires urandom + skip_tests.add("extmod/heapq1.py") # heapq not supported by WiPy + skip_tests.add("extmod/random_basic.py") # requires random + skip_tests.add("extmod/random_extra.py") # requires random elif args.target == "esp8266": skip_tests.add("misc/rge_sm.py") # too large elif args.target == "minimal": @@ -582,7 +582,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): skip_tests.add("micropython/opt_level.py") # don't assume line numbers are stored elif args.target == "nrf": skip_tests.add("basics/memoryview1.py") # no item assignment for memoryview - skip_tests.add("extmod/urandom_basic.py") # unimplemented: urandom.seed + skip_tests.add("extmod/random_basic.py") # unimplemented: random.seed skip_tests.add("micropython/opt_level.py") # no support for line numbers skip_tests.add("misc/non_compliant.py") # no item assignment for bytearray for t in tests: @@ -590,7 +590,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): skip_tests.add(t) elif args.target == "renesas-ra": skip_tests.add( - "extmod/utime_time_ns.py" + "extmod/time_time_ns.py" ) # RA fsp rtc function doesn't support nano sec info elif args.target == "qemu-arm": skip_tests.add("misc/print_exception.py") # requires sys stdfiles diff --git a/tests/stress/recursive_data.py b/tests/stress/recursive_data.py index 3b7fa509525..6e01319ed3a 100644 --- a/tests/stress/recursive_data.py +++ b/tests/stress/recursive_data.py @@ -1,6 +1,6 @@ # This tests that printing recursive data structure doesn't lead to segfault. try: - import uio as io + import io except ImportError: print("SKIP") raise SystemExit diff --git a/tests/thread/stress_aes.py b/tests/thread/stress_aes.py index aaf9f576dd5..b25da855aef 100644 --- a/tests/thread/stress_aes.py +++ b/tests/thread/stress_aes.py @@ -216,10 +216,7 @@ def apply_to(self, data): ################################################################## # test code -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/stress_create.py b/tests/thread/stress_create.py index 877424cdf50..98f272f5cd3 100644 --- a/tests/thread/stress_create.py +++ b/tests/thread/stress_create.py @@ -1,13 +1,12 @@ # stress test for creating many threads -try: - import utime - - sleep_ms = utime.sleep_ms -except ImportError: - import time +import time +if hasattr(time, "sleep_ms"): + sleep_ms = time.sleep_ms +else: sleep_ms = lambda t: time.sleep(t / 1000) + import _thread diff --git a/tests/thread/stress_heap.py b/tests/thread/stress_heap.py index 2ad91ae1476..dec65c7ce05 100644 --- a/tests/thread/stress_heap.py +++ b/tests/thread/stress_heap.py @@ -3,10 +3,7 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/stress_schedule.py b/tests/thread/stress_schedule.py index 8be7f2d7378..40191e66209 100644 --- a/tests/thread/stress_schedule.py +++ b/tests/thread/stress_schedule.py @@ -2,7 +2,7 @@ # while dealing with concurrent access from multiple threads. import _thread -import utime +import time import micropython import gc @@ -32,15 +32,15 @@ def thread(): micropython.schedule(task, None) except RuntimeError: # Queue full, back off. - utime.sleep_ms(10) + time.sleep_ms(10) for i in range(8): _thread.start_new_thread(thread, ()) # Wait up to 10 seconds for 10000 tasks to be scheduled. -t = utime.ticks_ms() -while n < _NUM_TASKS and utime.ticks_diff(utime.ticks_ms(), t) < _TIMEOUT_MS: +t = time.ticks_ms() +while n < _NUM_TASKS and time.ticks_diff(time.ticks_ms(), t) < _TIMEOUT_MS: pass if n < _NUM_TASKS: diff --git a/tests/thread/thread_exc2.py b/tests/thread/thread_exc2.py index 2863e1dec12..6f77bdbffaa 100644 --- a/tests/thread/thread_exc2.py +++ b/tests/thread/thread_exc2.py @@ -1,5 +1,5 @@ # test raising exception within thread which is not caught -import utime +import time import _thread @@ -8,5 +8,5 @@ def thread_entry(): _thread.start_new_thread(thread_entry, ()) -utime.sleep(1) +time.sleep(1) print("done") diff --git a/tests/thread/thread_exit1.py b/tests/thread/thread_exit1.py index 186a9be340b..e34ca827ca3 100644 --- a/tests/thread/thread_exit1.py +++ b/tests/thread/thread_exit1.py @@ -2,10 +2,7 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_exit2.py b/tests/thread/thread_exit2.py index 5be7945db22..630b6647582 100644 --- a/tests/thread/thread_exit2.py +++ b/tests/thread/thread_exit2.py @@ -2,10 +2,7 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_lock2.py b/tests/thread/thread_lock2.py index b842f69c937..96b3a6af809 100644 --- a/tests/thread/thread_lock2.py +++ b/tests/thread/thread_lock2.py @@ -2,10 +2,7 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime as time -except ImportError: - import time +import time import _thread lock = _thread.allocate_lock() diff --git a/tests/thread/thread_lock4.py b/tests/thread/thread_lock4.py index bbf90439961..97c3dc53800 100644 --- a/tests/thread/thread_lock4.py +++ b/tests/thread/thread_lock4.py @@ -2,10 +2,7 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_qstr1.py b/tests/thread/thread_qstr1.py index 14f5b6be664..f184d2a58e1 100644 --- a/tests/thread/thread_qstr1.py +++ b/tests/thread/thread_qstr1.py @@ -2,10 +2,7 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_sleep1.py b/tests/thread/thread_sleep1.py index 18fa4e05a11..add9b02f157 100644 --- a/tests/thread/thread_sleep1.py +++ b/tests/thread/thread_sleep1.py @@ -2,13 +2,11 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime - - sleep_ms = utime.sleep_ms -except ImportError: - import time +import time +if hasattr(time, "sleep_ms"): + sleep_ms = time.sleep_ms +else: sleep_ms = lambda t: time.sleep(t / 1000) import _thread diff --git a/tests/thread/thread_stacksize1.py b/tests/thread/thread_stacksize1.py index cf46b73b770..140d165cb34 100644 --- a/tests/thread/thread_stacksize1.py +++ b/tests/thread/thread_stacksize1.py @@ -1,10 +1,8 @@ # test setting the thread stack size # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import usys as sys -except ImportError: - import sys + +import sys import _thread # different implementations have different minimum sizes diff --git a/tests/thread/thread_start1.py b/tests/thread/thread_start1.py index 7274633245a..ea8c4f00025 100644 --- a/tests/thread/thread_start1.py +++ b/tests/thread/thread_start1.py @@ -2,10 +2,7 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_start2.py b/tests/thread/thread_start2.py index d68ea94329b..f8239a779a6 100644 --- a/tests/thread/thread_start2.py +++ b/tests/thread/thread_start2.py @@ -2,10 +2,7 @@ # # MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/unicode/unicode_ure.py b/tests/unicode/unicode_ure.py index 5a5dc600545..c268b9e6fe9 100644 --- a/tests/unicode/unicode_ure.py +++ b/tests/unicode/unicode_ure.py @@ -1,13 +1,10 @@ # test match.span() for unicode strings try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: m = re.match(".", "a") diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py index 3c12b26923a..0ea8f7886bf 100644 --- a/tests/unix/extra_coverage.py +++ b/tests/unix/extra_coverage.py @@ -4,8 +4,8 @@ print("SKIP") raise SystemExit -import uerrno -import uio +import errno +import io data = extra_coverage() @@ -18,7 +18,7 @@ # test streams stream = data[2] # has set_error and set_buf. Write always returns error -stream.set_error(uerrno.EAGAIN) # non-blocking error +stream.set_error(errno.EAGAIN) # non-blocking error print(stream.read()) # read all encounters non-blocking error print(stream.read(1)) # read 1 byte encounters non-blocking error print(stream.readline()) # readline encounters non-blocking error @@ -42,8 +42,8 @@ print(stream2.read(1)) # read 1 byte encounters non-blocking error with textio stream # test BufferedWriter with stream errors -stream.set_error(uerrno.EAGAIN) -buf = uio.BufferedWriter(stream, 8) +stream.set_error(errno.EAGAIN) +buf = io.BufferedWriter(stream, 8) print(buf.write(bytearray(16))) # function defined in C++ code diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 7ea2599c919..6ec8eaaa044 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -48,21 +48,21 @@ RuntimeError: RuntimeError: # repl ame__ -mport +port builtins micropython _thread _uasyncio -btree cexample cmath cppexample -example_package ffi framebuf -gc math termios uarray -ubinascii ucollections ucryptolib uctypes -uerrno uhashlib uheapq uio -ujson umachine uos urandom -ure uselect usocket ussl -ustruct usys utime utimeq -uwebsocket uzlib -ime +array binascii btree cexample +cmath collections cppexample cryptolib +errno example_package ffi +framebuf gc hashlib heapq +io json machine math +os random re select +socket ssl struct sys +termios time timeq uctypes +websocket zlib +me -utime utimeq +time timeq argv atexit byteorder exc_info executable exit getsizeof implementation diff --git a/tests/unix/ffi_types.py b/tests/unix/ffi_types.py index fd94c509d05..06e9b89d3fe 100644 --- a/tests/unix/ffi_types.py +++ b/tests/unix/ffi_types.py @@ -1,7 +1,7 @@ # test 8/16/32/64 bit signed/unsigned integer arguments and return types for ffi functions # requires ffi_lib.c to be compiled as: $(CC) -shared -o ffi_lib.so ffi_lib.c -import uos, usys +import os, sys try: import ffi @@ -9,9 +9,9 @@ print("SKIP") raise SystemExit -ffi_lib_filename = "./" + usys.argv[0].rsplit("/", 1)[0] + "/ffi_lib.so" +ffi_lib_filename = "./" + sys.argv[0].rsplit("/", 1)[0] + "/ffi_lib.so" try: - uos.stat(ffi_lib_filename) + os.stat(ffi_lib_filename) except OSError: print("SKIP") raise SystemExit diff --git a/tests/unix/time.py b/tests/unix/time_mktime_localtime.py similarity index 96% rename from tests/unix/time.py rename to tests/unix/time_mktime_localtime.py index 55a4b18aaef..d1c03c103d7 100644 --- a/tests/unix/time.py +++ b/tests/unix/time_mktime_localtime.py @@ -1,7 +1,4 @@ -try: - import utime as time -except ImportError: - import time +import time DAYS_PER_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] diff --git a/tests/wipy/wlan/machine.py.exp b/tests/wipy/wlan/machine.py.exp index cc5b3f61dab..303a0633a65 100644 --- a/tests/wipy/wlan/machine.py.exp +++ b/tests/wipy/wlan/machine.py.exp @@ -1,4 +1,4 @@ - + True True Active diff --git a/tools/ci.sh b/tools/ci.sh index 21acc17535b..a010adcbce7 100755 --- a/tools/ci.sh +++ b/tools/ci.sh @@ -630,8 +630,8 @@ function ci_unix_macos_build { function ci_unix_macos_run_tests { # Issues with macOS tests: # - import_pkg7 has a problem with relative imports - # - urandom_basic has a problem with getrandbits(0) - (cd tests && MICROPY_MICROPYTHON=../ports/unix/build-standard/micropython ./run-tests.py --exclude 'import_pkg7.py' --exclude 'urandom_basic.py') + # - random_basic has a problem with getrandbits(0) + (cd tests && MICROPY_MICROPYTHON=../ports/unix/build-standard/micropython ./run-tests.py --exclude 'import_pkg7.py' --exclude 'random_basic.py') } function ci_unix_qemu_mips_setup { diff --git a/tools/tinytest-codegen.py b/tools/tinytest-codegen.py index feda75f283d..d6e87ac6ce2 100755 --- a/tools/tinytest-codegen.py +++ b/tools/tinytest-codegen.py @@ -65,11 +65,11 @@ def script_to_map(test_file): "basics/bytes_compare3.py", "extmod/ticks_diff.py", "extmod/time_ms_us.py", - "extmod/uheapq_timeq.py", + "extmod/heapq_timeq.py", # unicode char issue - "extmod/ujson_loads.py", + "extmod/json_loads.py", # doesn't output to python stdout - "extmod/ure_debug.py", + "extmod/re_debug.py", "extmod/vfs_basic.py", "extmod/vfs_fat_ramdisk.py", "extmod/vfs_fat_fileio.py", From 109717457edbf49421af3848ea26e26fff567289 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 2 Jun 2023 15:23:23 +1000 Subject: [PATCH 0023/4300] tests/run-multitests.py: Don't allow imports from the cwd. Make tests run in an isolated environment (i.e. `import io` would otherwise get the `tests/io` directory). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- tests/run-multitests.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/run-multitests.py b/tests/run-multitests.py index 81db31ea94e..5ae8b8ea480 100755 --- a/tests/run-multitests.py +++ b/tests/run-multitests.py @@ -162,6 +162,14 @@ def __init__(self, argv, env=None): def __str__(self): return self.argv[0].rsplit("/")[-1] + def prepare_script_from_file(self, filename, prepend, append): + # Make tests run in an isolated environment (i.e. `import io` would + # otherwise get the `tests/io` directory). + remove_cwd_from_sys_path = b"import sys\nsys.path.remove('')\n\n" + return remove_cwd_from_sys_path + super().prepare_script_from_file( + filename, prepend, append + ) + def run_script(self, script): output = b"" err = None @@ -582,7 +590,7 @@ def main(): cmd_args = cmd_parser.parse_args() # clear search path to make sure tests use only builtin modules and those in extmod - os.environ["MICROPYPATH"] = os.pathsep.join(("", ".frozen", "../extmod")) + os.environ["MICROPYPATH"] = os.pathsep.join((".frozen", "../extmod")) test_files = prepare_test_file_list(cmd_args.files) max_instances = max(t[1] for t in test_files) From 339f02a5947e79347014b4d34adbf8a120b184bc Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 2 Jun 2023 15:40:03 +1000 Subject: [PATCH 0024/4300] tests/run-perfbench.py: Don't allow imports from the cwd. Make tests run in an isolated environment (i.e. `import io` would otherwise get the `tests/io` directory). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- tests/perf_bench/core_import_mpy_multi.py | 4 ++-- tests/perf_bench/core_import_mpy_single.py | 6 +++--- tests/run-perfbench.py | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/perf_bench/core_import_mpy_multi.py b/tests/perf_bench/core_import_mpy_multi.py index ce68306678b..364c3250428 100644 --- a/tests/perf_bench/core_import_mpy_multi.py +++ b/tests/perf_bench/core_import_mpy_multi.py @@ -47,7 +47,7 @@ def chdir(self, path): pass def stat(self, path): - if path == "__injected.mpy": + if path == "/__injected.mpy": return tuple(0 for _ in range(10)) else: raise OSError(-2) # ENOENT @@ -58,7 +58,7 @@ def open(self, path, mode): def mount(): os.mount(FS(), "/__remote") - os.chdir("/__remote") + sys.path.insert(0, "/__remote") def test(r): diff --git a/tests/perf_bench/core_import_mpy_single.py b/tests/perf_bench/core_import_mpy_single.py index 1b411fc3fb6..5757c3eaf1f 100644 --- a/tests/perf_bench/core_import_mpy_single.py +++ b/tests/perf_bench/core_import_mpy_single.py @@ -2,7 +2,7 @@ # The first import of a module will intern strings that don't already exist, and # this test should be representative of what happens in a real application. -import io, os +import io, os, sys if not (hasattr(io, "IOBase") and hasattr(os, "mount")): print("SKIP") @@ -102,7 +102,7 @@ def chdir(self, path): pass def stat(self, path): - if path == "__injected.mpy": + if path == "/__injected.mpy": return tuple(0 for _ in range(10)) else: raise OSError(-2) # ENOENT @@ -113,7 +113,7 @@ def open(self, path, mode): def mount(): os.mount(FS(), "/__remote") - os.chdir("/__remote") + sys.path.insert(0, "/__remote") def test(): diff --git a/tests/run-perfbench.py b/tests/run-perfbench.py index 578f975bb84..81d873c4599 100755 --- a/tests/run-perfbench.py +++ b/tests/run-perfbench.py @@ -109,8 +109,9 @@ def run_benchmarks(args, target, param_n, param_m, n_average, test_list): continue # Create test script + test_script = b"import sys\nsys.path.remove('')\n\n" with open(test_file, "rb") as f: - test_script = f.read() + test_script += f.read() with open(BENCH_SCRIPT_DIR + "benchrun.py", "rb") as f: test_script += f.read() test_script += b"bm_run(%u, %u)\n" % (param_n, param_m) From 9d7eac07138b6e02f4c0775dc70f36fdd69432a2 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 2 Jun 2023 17:58:27 +1000 Subject: [PATCH 0025/4300] tests/run-natmodtests.py: Don't allow imports from the cwd. Make tests run in an isolated environment (i.e. `import io` would otherwise get the `tests/io` directory). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- tests/run-natmodtests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/run-natmodtests.py b/tests/run-natmodtests.py index 9fe970a6d09..16f8fde967b 100755 --- a/tests/run-natmodtests.py +++ b/tests/run-natmodtests.py @@ -46,14 +46,14 @@ def mount(self, readonly, mkfs): def chdir(self, path): pass def stat(self, path): - if path == '__injected.mpy': + if path == '/__injected.mpy': return tuple(0 for _ in range(10)) else: raise OSError(-2) # ENOENT def open(self, path, mode): return __File() os.mount(__FS(), '/__remote') -os.chdir('/__remote') +sys.path.insert(0, '/__remote') sys.modules['{}'] = __import__('__injected') """ @@ -111,9 +111,10 @@ def run_tests(target_truth, target, args, stats): test_file_data = f.read() # Create full test with embedded .mpy + test_script = b"import sys\nsys.path.remove('')\n\n" try: with open(NATMOD_EXAMPLE_DIR + test_mpy, "rb") as f: - test_script = b"__buf=" + bytes(repr(f.read()), "ascii") + b"\n" + test_script += b"__buf=" + bytes(repr(f.read()), "ascii") + b"\n" except OSError: print("---- {} - mpy file not compiled".format(test_file)) continue From 5fd042e7d1610b4d42acfc523441468f2ac28c6f Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 19 Aug 2022 22:58:37 +1000 Subject: [PATCH 0026/4300] all: Replace all uses of umodule in Python code. Applies to drivers/examples/extmod/port-modules/tools. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- examples/hwapi/README.md | 6 +-- examples/hwapi/button_led.py | 4 +- examples/hwapi/button_reaction.py | 4 +- examples/hwapi/soft_pwm.py | 6 +-- examples/network/http_client.py | 5 +-- examples/network/http_client_ssl.py | 14 ++----- examples/network/http_server.py | 5 +-- examples/network/http_server_simplistic.py | 5 +-- .../http_server_simplistic_commented.py | 5 +-- examples/network/http_server_ssl.py | 10 ++--- examples/unix/machine_bios.py | 2 +- extmod/uasyncio/event.py | 4 +- extmod/uasyncio/stream.py | 6 +-- ports/esp32/modules/_boot.py | 4 +- ports/esp32/modules/inisetup.py | 8 ++-- ports/esp8266/boards/GENERIC/board.md | 2 +- ports/esp8266/boards/GENERIC_1M/board.md | 2 +- ports/esp8266/modules/_boot.py | 4 +- ports/esp8266/modules/espnow.py | 2 +- ports/esp8266/modules/inisetup.py | 18 ++++----- ports/nrf/modules/scripts/_mkfs.py | 14 +++---- ports/rp2/modules/rp2.py | 4 +- ports/samd/modules/_boot.py | 8 ++-- .../boards/NUCLEO_WB55/rfcore_firmware.py | 2 +- ports/stm32/mboot/fwupdate.py | 6 +-- tools/mpremote/mpremote/commands.py | 4 +- tools/mpremote/mpremote/main.py | 2 +- tools/mpremote/mpremote/transport_serial.py | 38 +++++++++---------- tools/pyboard.py | 26 ++++++------- 29 files changed, 99 insertions(+), 121 deletions(-) diff --git a/examples/hwapi/README.md b/examples/hwapi/README.md index f3de752f9c0..a1b0c5642a2 100644 --- a/examples/hwapi/README.md +++ b/examples/hwapi/README.md @@ -40,13 +40,13 @@ application of this idea would look like: `app.py`: from hwconfig import * - import utime + import time while True: LED.value(1) - utime.sleep_ms(500) + time.sleep_ms(500) LED.value(0) - utime.sleep_ms(500) + time.sleep_ms(500) To deploy this application to a particular board, a user will need: diff --git a/examples/hwapi/button_led.py b/examples/hwapi/button_led.py index bd6fe017298..c73bcfc89a2 100644 --- a/examples/hwapi/button_led.py +++ b/examples/hwapi/button_led.py @@ -1,4 +1,4 @@ -import utime +import time from hwconfig import LED, BUTTON # Light LED when (and while) a BUTTON is pressed @@ -6,4 +6,4 @@ while 1: LED.value(BUTTON.value()) # Don't burn CPU - utime.sleep_ms(10) + time.sleep_ms(10) diff --git a/examples/hwapi/button_reaction.py b/examples/hwapi/button_reaction.py index e5a139a575f..52bdf793849 100644 --- a/examples/hwapi/button_reaction.py +++ b/examples/hwapi/button_reaction.py @@ -1,4 +1,4 @@ -import utime +import time import machine from hwconfig import LED, BUTTON @@ -18,4 +18,4 @@ print("Well, you're *really* slow") else: print("You are as slow as %d microseconds!" % delay) - utime.sleep_ms(10) + time.sleep_ms(10) diff --git a/examples/hwapi/soft_pwm.py b/examples/hwapi/soft_pwm.py index 72291b0ecde..466de08f09b 100644 --- a/examples/hwapi/soft_pwm.py +++ b/examples/hwapi/soft_pwm.py @@ -1,4 +1,4 @@ -import utime +import time from hwconfig import LED @@ -15,10 +15,10 @@ def pwm_cycle(led, duty, cycles): for i in range(cycles): if duty: led.on() - utime.sleep_ms(duty) + time.sleep_ms(duty) if duty_off: led.off() - utime.sleep_ms(duty_off) + time.sleep_ms(duty_off) # At the duty setting of 1, an LED is still pretty bright, then diff --git a/examples/network/http_client.py b/examples/network/http_client.py index 0791c8066b6..661c286b70b 100644 --- a/examples/network/http_client.py +++ b/examples/network/http_client.py @@ -1,7 +1,4 @@ -try: - import usocket as socket -except: - import socket +import socket def main(use_stream=False): diff --git a/examples/network/http_client_ssl.py b/examples/network/http_client_ssl.py index 83f685fdf35..323971c0ee2 100644 --- a/examples/network/http_client_ssl.py +++ b/examples/network/http_client_ssl.py @@ -1,17 +1,11 @@ -try: - import usocket as _socket -except: - import _socket -try: - import ussl as ssl -except: - import ssl +import socket +import ssl def main(use_stream=True): - s = _socket.socket() + s = socket.socket() - ai = _socket.getaddrinfo("google.com", 443) + ai = socket.getaddrinfo("google.com", 443) print("Address infos:", ai) addr = ai[0][-1] diff --git a/examples/network/http_server.py b/examples/network/http_server.py index 76be3ab8173..a6ed53154a4 100644 --- a/examples/network/http_server.py +++ b/examples/network/http_server.py @@ -1,7 +1,4 @@ -try: - import usocket as socket -except: - import socket +import socket CONTENT = b"""\ diff --git a/examples/network/http_server_simplistic.py b/examples/network/http_server_simplistic.py index a9831127ff0..09936b9d91e 100644 --- a/examples/network/http_server_simplistic.py +++ b/examples/network/http_server_simplistic.py @@ -1,9 +1,6 @@ # Do not use this code in real projects! Read # http_server_simplistic_commented.py for details. -try: - import usocket as socket -except: - import socket +import socket CONTENT = b"""\ diff --git a/examples/network/http_server_simplistic_commented.py b/examples/network/http_server_simplistic_commented.py index da042c6c8a5..d4710ad61a6 100644 --- a/examples/network/http_server_simplistic_commented.py +++ b/examples/network/http_server_simplistic_commented.py @@ -8,10 +8,7 @@ # details, and use this code only for quick hacks, preferring # http_server.py for "real thing". # -try: - import usocket as socket -except: - import socket +import socket CONTENT = b"""\ diff --git a/examples/network/http_server_ssl.py b/examples/network/http_server_ssl.py index 1116c71e996..7766fa7ea56 100644 --- a/examples/network/http_server_ssl.py +++ b/examples/network/http_server_ssl.py @@ -1,10 +1,6 @@ -import ubinascii as binascii - -try: - import usocket as socket -except: - import socket -import ussl as ssl +import binascii +import socket +import ssl # This self-signed key/cert pair is randomly generated and to be used for diff --git a/examples/unix/machine_bios.py b/examples/unix/machine_bios.py index 878f3fd8f3c..40aae4ccefe 100644 --- a/examples/unix/machine_bios.py +++ b/examples/unix/machine_bios.py @@ -4,6 +4,6 @@ # It is expected to print 0xaa55, which is a signature at the start of # Video BIOS. -import umachine as machine +import machine print(hex(machine.mem16[0xC0000])) diff --git a/extmod/uasyncio/event.py b/extmod/uasyncio/event.py index 43d47eb5f06..8a905345907 100644 --- a/extmod/uasyncio/event.py +++ b/extmod/uasyncio/event.py @@ -40,9 +40,9 @@ def wait(self): # that asyncio will poll until a flag is set. # Note: Unlike Event, this is self-clearing after a wait(). try: - import uio + import io - class ThreadSafeFlag(uio.IOBase): + class ThreadSafeFlag(io.IOBase): def __init__(self): self.state = 0 diff --git a/extmod/uasyncio/stream.py b/extmod/uasyncio/stream.py index 875353c940f..ac297cce04d 100644 --- a/extmod/uasyncio/stream.py +++ b/extmod/uasyncio/stream.py @@ -101,8 +101,8 @@ def drain(self): # # async def open_connection(host, port): - from uerrno import EINPROGRESS - import usocket as socket + from errno import EINPROGRESS + import socket ai = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)[0] # TODO this is blocking! s = socket.socket(ai[0], ai[1], ai[2]) @@ -154,7 +154,7 @@ async def _serve(self, s, cb): # Helper function to start a TCP stream server, running as a new task # TODO could use an accept-callback on socket read activity instead of creating a task async def start_server(cb, host, port, backlog=5): - import usocket as socket + import socket # Create and bind server socket. host = socket.getaddrinfo(host, port)[0] # TODO this is blocking! diff --git a/ports/esp32/modules/_boot.py b/ports/esp32/modules/_boot.py index a7d9813090b..651fc7b10cd 100644 --- a/ports/esp32/modules/_boot.py +++ b/ports/esp32/modules/_boot.py @@ -1,10 +1,10 @@ import gc -import uos +import os from flashbdev import bdev try: if bdev: - uos.mount(bdev, "/") + os.mount(bdev, "/") except OSError: import inisetup diff --git a/ports/esp32/modules/inisetup.py b/ports/esp32/modules/inisetup.py index 426a47a6b45..35d1c6bc9a8 100644 --- a/ports/esp32/modules/inisetup.py +++ b/ports/esp32/modules/inisetup.py @@ -1,4 +1,4 @@ -import uos +import os from flashbdev import bdev @@ -33,9 +33,9 @@ def fs_corrupted(): def setup(): check_bootsec() print("Performing initial setup") - uos.VfsLfs2.mkfs(bdev) - vfs = uos.VfsLfs2(bdev) - uos.mount(vfs, "/") + os.VfsLfs2.mkfs(bdev) + vfs = os.VfsLfs2(bdev) + os.mount(vfs, "/") with open("boot.py", "w") as f: f.write( """\ diff --git a/ports/esp8266/boards/GENERIC/board.md b/ports/esp8266/boards/GENERIC/board.md index b93ca509f89..fa0cf410d66 100644 --- a/ports/esp8266/boards/GENERIC/board.md +++ b/ports/esp8266/boards/GENERIC/board.md @@ -6,7 +6,7 @@ Note: v1.12-334 and newer (including v1.13) require an ESP8266 module with 2MiB of flash or more, and use littlefs as the filesystem by default. When upgrading from older firmware please backup your files first, and either erase all flash before upgrading, or after upgrading execute -`uos.VfsLfs2.mkfs(bdev)`. +`os.VfsLfs2.mkfs(bdev)`. ### OTA builds Over-The-Air (OTA) builds of the ESP8266 firmware are also provided. diff --git a/ports/esp8266/boards/GENERIC_1M/board.md b/ports/esp8266/boards/GENERIC_1M/board.md index 4a0e6770787..17cc6e3a6bd 100644 --- a/ports/esp8266/boards/GENERIC_1M/board.md +++ b/ports/esp8266/boards/GENERIC_1M/board.md @@ -2,4 +2,4 @@ The following are daily builds of the ESP8266 firmware tailored for modules with only 1MiB of flash. This firmware uses littlefs as the filesystem. When upgrading from older firmware that uses a FAT filesystem please backup your files first, and either erase all flash before upgrading, or after upgrading execute -`uos.VfsLfs2.mkfs(bdev)`. +`os.VfsLfs2.mkfs(bdev)`. diff --git a/ports/esp8266/modules/_boot.py b/ports/esp8266/modules/_boot.py index 1f77d880246..06b372990a5 100644 --- a/ports/esp8266/modules/_boot.py +++ b/ports/esp8266/modules/_boot.py @@ -1,12 +1,12 @@ import gc gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4) -import uos +import os from flashbdev import bdev if bdev: try: - uos.mount(bdev, "/") + os.mount(bdev, "/") except: import inisetup diff --git a/ports/esp8266/modules/espnow.py b/ports/esp8266/modules/espnow.py index 2f9c256c6b4..1d2b946552e 100644 --- a/ports/esp8266/modules/espnow.py +++ b/ports/esp8266/modules/espnow.py @@ -2,7 +2,7 @@ # MIT license; Copyright (c) 2022 Glenn Moloney @glenn20 from _espnow import * -from uselect import poll, POLLIN +from select import poll, POLLIN class ESPNow(ESPNowBase): diff --git a/ports/esp8266/modules/inisetup.py b/ports/esp8266/modules/inisetup.py index e5ce00138ec..fa6a93fd839 100644 --- a/ports/esp8266/modules/inisetup.py +++ b/ports/esp8266/modules/inisetup.py @@ -1,13 +1,13 @@ -import uos +import os import network from flashbdev import bdev def wifi(): - import ubinascii + import binascii ap_if = network.WLAN(network.AP_IF) - ssid = b"MicroPython-%s" % ubinascii.hexlify(ap_if.config("mac")[-3:]) + ssid = b"MicroPython-%s" % binascii.hexlify(ap_if.config("mac")[-3:]) ap_if.config(ssid=ssid, security=network.AUTH_WPA_WPA2_PSK, key=b"micropythoN") @@ -32,7 +32,7 @@ def fs_corrupted(): """\ The filesystem starting at sector %d with size %d sectors looks corrupt. You may want to make a flash snapshot and try to recover it. Otherwise, -format it with uos.VfsLfs2.mkfs(bdev), or completely erase the flash and +format it with os.VfsLfs2.mkfs(bdev), or completely erase the flash and reprogram MicroPython. """ % (bdev.start_sec, bdev.blocks) @@ -44,17 +44,17 @@ def setup(): check_bootsec() print("Performing initial setup") wifi() - uos.VfsLfs2.mkfs(bdev) - vfs = uos.VfsLfs2(bdev) - uos.mount(vfs, "/") + os.VfsLfs2.mkfs(bdev) + vfs = os.VfsLfs2(bdev) + os.mount(vfs, "/") with open("boot.py", "w") as f: f.write( """\ # This file is executed on every boot (including wake-boot from deepsleep) #import esp #esp.osdebug(None) -import uos, machine -#uos.dupterm(None, 1) # disable REPL on UART(0) +import os, machine +#os.dupterm(None, 1) # disable REPL on UART(0) import gc #import webrepl #webrepl.start() diff --git a/ports/nrf/modules/scripts/_mkfs.py b/ports/nrf/modules/scripts/_mkfs.py index 00522ffbb93..02e8dabce28 100644 --- a/ports/nrf/modules/scripts/_mkfs.py +++ b/ports/nrf/modules/scripts/_mkfs.py @@ -1,19 +1,19 @@ -import uos, nrf +import os, nrf try: - from uos import VfsLfs1 + from os import VfsLfs1 - uos.VfsLfs1.mkfs(nrf.Flash()) + os.VfsLfs1.mkfs(nrf.Flash()) except ImportError: try: - from uos import VfsLfs2 + from os import VfsLfs2 - uos.VfsLfs2.mkfs(nrf.Flash()) + os.VfsLfs2.mkfs(nrf.Flash()) except ImportError: try: - from uos import VfsFat + from os import VfsFat - uos.VfsFat.mkfs(nrf.Flash()) + os.VfsFat.mkfs(nrf.Flash()) except ImportError: pass except OSError as e: diff --git a/ports/rp2/modules/rp2.py b/ports/rp2/modules/rp2.py index f145cbd6077..a34e8e92a34 100644 --- a/ports/rp2/modules/rp2.py +++ b/ports/rp2/modules/rp2.py @@ -34,9 +34,9 @@ def __init__( pull_thresh=32, fifo_join=0 ): - # uarray is a built-in module so importing it here won't require + # array is a built-in module so importing it here won't require # scanning the filesystem. - from uarray import array + from array import array self.labels = {} execctrl = 0 diff --git a/ports/samd/modules/_boot.py b/ports/samd/modules/_boot.py index 5fe2bc640c5..1ff51de5988 100644 --- a/ports/samd/modules/_boot.py +++ b/ports/samd/modules/_boot.py @@ -1,19 +1,19 @@ import gc -import uos +import os import samd bdev = samd.Flash() # Try to mount the filesystem, and format the flash if it doesn't exist. -fs_type = uos.VfsLfs2 if hasattr(uos, "VfsLfs2") else uos.VfsLfs1 +fs_type = os.VfsLfs2 if hasattr(os, "VfsLfs2") else os.VfsLfs1 try: vfs = fs_type(bdev, progsize=256) except: fs_type.mkfs(bdev, progsize=256) vfs = fs_type(bdev, progsize=256) -uos.mount(vfs, "/") +os.mount(vfs, "/") -del vfs, fs_type, bdev, uos, samd +del vfs, fs_type, bdev, os, samd gc.collect() del gc diff --git a/ports/stm32/boards/NUCLEO_WB55/rfcore_firmware.py b/ports/stm32/boards/NUCLEO_WB55/rfcore_firmware.py index fe34ce12286..3c741e575ca 100644 --- a/ports/stm32/boards/NUCLEO_WB55/rfcore_firmware.py +++ b/ports/stm32/boards/NUCLEO_WB55/rfcore_firmware.py @@ -73,7 +73,7 @@ try: import machine, stm - from ubinascii import crc32 + from binascii import crc32 from micropython import const except ImportError: # cpython diff --git a/ports/stm32/mboot/fwupdate.py b/ports/stm32/mboot/fwupdate.py index 4bf07f5a33e..78a8d73658b 100644 --- a/ports/stm32/mboot/fwupdate.py +++ b/ports/stm32/mboot/fwupdate.py @@ -3,7 +3,7 @@ from micropython import const import struct, time -import uzlib, machine, stm +import zlib, machine, stm # Constants to be used with update_mpy VFS_FAT = 1 @@ -36,7 +36,7 @@ def dfu_read(filename): if hdr == b"Dfu": pass elif hdr == b"\x1f\x8b\x08": - f = uzlib.DecompIO(f, 16 + 15) + f = zlib.DecompIO(f, 16 + 15) else: print("Invalid firmware", filename) return None @@ -231,7 +231,7 @@ def update_app_elements( # Check firmware is of .dfu or .dfu.gz type try: with open(filename, "rb") as f: - hdr = uzlib.DecompIO(f, 16 + 15).read(6) + hdr = zlib.DecompIO(f, 16 + 15).read(6) except Exception: with open(filename, "rb") as f: hdr = f.read(6) diff --git a/tools/mpremote/mpremote/commands.py b/tools/mpremote/mpremote/commands.py index 45acb8da19e..ef1a7643cb9 100644 --- a/tools/mpremote/mpremote/commands.py +++ b/tools/mpremote/mpremote/commands.py @@ -137,14 +137,14 @@ def _list_recursive(files, path): raise CommandError("'cp -r' source files must be local") _list_recursive(src_files, path) known_dirs = {""} - state.transport.exec_("import uos") + state.transport.exec_("import os") for dir, file in src_files: dir_parts = dir.split("/") for i in range(len(dir_parts)): d = "/".join(dir_parts[: i + 1]) if d not in known_dirs: state.transport.exec_( - "try:\n uos.mkdir('%s')\nexcept OSError as e:\n print(e)" % d + "try:\n os.mkdir('%s')\nexcept OSError as e:\n print(e)" % d ) known_dirs.add(d) state.transport.filesystem_command( diff --git a/tools/mpremote/mpremote/main.py b/tools/mpremote/mpremote/main.py index 6689266098b..eeb9cbd9893 100644 --- a/tools/mpremote/mpremote/main.py +++ b/tools/mpremote/mpremote/main.py @@ -317,7 +317,7 @@ def argparse_none(description): # Disk used/free. "df": [ "exec", - "import uos\nprint('mount \\tsize \\tused \\tavail \\tuse%')\nfor _m in [''] + uos.listdir('/'):\n _s = uos.stat('/' + _m)\n if not _s[0] & 1 << 14: continue\n _s = uos.statvfs(_m)\n if _s[0]:\n _size = _s[0] * _s[2]; _free = _s[0] * _s[3]; print(_m, _size, _size - _free, _free, int(100 * (_size - _free) / _size), sep='\\t')", + "import os\nprint('mount \\tsize \\tused \\tavail \\tuse%')\nfor _m in [''] + os.listdir('/'):\n _s = os.stat('/' + _m)\n if not _s[0] & 1 << 14: continue\n _s = os.statvfs(_m)\n if _s[0]:\n _size = _s[0] * _s[2]; _free = _s[0] * _s[3]; print(_m, _size, _size - _free, _free, int(100 * (_size - _free) / _size), sep='\\t')", ], # Other shortcuts. "reset": { diff --git a/tools/mpremote/mpremote/transport_serial.py b/tools/mpremote/mpremote/transport_serial.py index 84822fe69cd..09025c30988 100644 --- a/tools/mpremote/mpremote/transport_serial.py +++ b/tools/mpremote/mpremote/transport_serial.py @@ -292,14 +292,14 @@ def execfile(self, filename): def fs_exists(self, src): try: - self.exec("import uos\nuos.stat(%s)" % (("'%s'" % src) if src else "")) + self.exec("import os\nos.stat(%s)" % (("'%s'" % src) if src else "")) return True except TransportError: return False def fs_ls(self, src): cmd = ( - "import uos\nfor f in uos.ilistdir(%s):\n" + "import os\nfor f in os.ilistdir(%s):\n" " print('{:12} {}{}'.format(f[3]if len(f)>3 else 0,f[0],'/'if f[1]&0x4000 else ''))" % (("'%s'" % src) if src else "") ) @@ -311,7 +311,7 @@ def fs_listdir(self, src=""): def repr_consumer(b): buf.extend(b.replace(b"\x04", b"")) - cmd = "import uos\nfor f in uos.ilistdir(%s):\n" " print(repr(f), end=',')" % ( + cmd = "import os\nfor f in os.ilistdir(%s):\n" " print(repr(f), end=',')" % ( ("'%s'" % src) if src else "" ) try: @@ -328,8 +328,8 @@ def repr_consumer(b): def fs_stat(self, src): try: - self.exec("import uos") - return os.stat_result(self.eval("uos.stat(%s)" % (("'%s'" % src)), parse=True)) + self.exec("import os") + return os.stat_result(self.eval("os.stat(%s)" % (("'%s'" % src)), parse=True)) except TransportError as e: reraise_filesystem_error(e, src) @@ -422,13 +422,13 @@ def fs_put(self, src, dest, chunk_size=256, progress_callback=None): self.exec("f.close()") def fs_mkdir(self, dir): - self.exec("import uos\nuos.mkdir('%s')" % dir) + self.exec("import os\nos.mkdir('%s')" % dir) def fs_rmdir(self, dir): - self.exec("import uos\nuos.rmdir('%s')" % dir) + self.exec("import os\nos.rmdir('%s')" % dir) def fs_rm(self, src): - self.exec("import uos\nuos.remove('%s')" % src) + self.exec("import os\nos.remove('%s')" % src) def fs_touch(self, src): self.exec("f=open('%s','a')\nf.close()" % src) @@ -595,7 +595,7 @@ def write_ctrl_d(self, out_callback): def umount_local(self): if self.mounted: - self.exec('uos.umount("/remote")') + self.exec('os.umount("/remote")') self.mounted = False self.serial = self.serial.orig_serial @@ -616,18 +616,18 @@ def umount_local(self): } fs_hook_code = """\ -import uos, uio, ustruct, micropython +import os, io, struct, micropython SEEK_SET = 0 class RemoteCommand: def __init__(self): - import uselect, usys + import select, sys self.buf4 = bytearray(4) - self.fout = usys.stdout.buffer - self.fin = usys.stdin.buffer - self.poller = uselect.poll() - self.poller.register(self.fin, uselect.POLLIN) + self.fout = sys.stdout.buffer + self.fin = sys.stdin.buffer + self.poller = select.poll() + self.poller.register(self.fin, select.POLLIN) def poll_in(self): for _ in self.poller.ipoll(1000): @@ -710,7 +710,7 @@ def wr_s8(self, i): self.fout.write(self.buf4, 1) def wr_s32(self, i): - ustruct.pack_into('3 else 0,f[0],'/'if f[1]&0x4000 else ''))" % (("'%s'" % src) if src else "") ) @@ -528,7 +528,7 @@ def fs_listdir(self, src=""): def repr_consumer(b): buf.extend(b.replace(b"\x04", b"")) - cmd = "import uos\nfor f in uos.ilistdir(%s):\n" " print(repr(f), end=',')" % ( + cmd = "import os\nfor f in os.ilistdir(%s):\n" " print(repr(f), end=',')" % ( ("'%s'" % src) if src else "" ) try: @@ -545,8 +545,8 @@ def repr_consumer(b): def fs_stat(self, src): try: - self.exec_("import uos") - return os.stat_result(self.eval("uos.stat(%s)" % (("'%s'" % src)), parse=True)) + self.exec_("import os") + return os.stat_result(self.eval("os.stat(%s)" % (("'%s'" % src)), parse=True)) except PyboardError as e: raise e.convert(src) @@ -639,13 +639,13 @@ def fs_put(self, src, dest, chunk_size=256, progress_callback=None): self.exec_("f.close()") def fs_mkdir(self, dir): - self.exec_("import uos\nuos.mkdir('%s')" % dir) + self.exec_("import os\nos.mkdir('%s')" % dir) def fs_rmdir(self, dir): - self.exec_("import uos\nuos.rmdir('%s')" % dir) + self.exec_("import os\nos.rmdir('%s')" % dir) def fs_rm(self, src): - self.exec_("import uos\nuos.remove('%s')" % src) + self.exec_("import os\nos.remove('%s')" % src) def fs_touch(self, src): self.exec_("f=open('%s','a')\nf.close()" % src) @@ -737,9 +737,9 @@ def fname_cp_dest(src, dest): _injected_import_hook_code = """\ -import uos, uio +import os, io class _FS: - class File(uio.IOBase): + class File(io.IOBase): def __init__(self): self.off = 0 def ioctl(self, request, arg): @@ -756,10 +756,10 @@ def stat(self, path): raise OSError(-2) # ENOENT def open(self, path, mode): return self.File() -uos.mount(_FS(), '/_') -uos.chdir('/_') +os.mount(_FS(), '/_') +os.chdir('/_') from _injected import * -uos.umount('/_') +os.umount('/_') del _injected_buf, _FS """ From 8211d56712301d58970904892da5312b11b2ab7c Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 2 Jun 2023 23:33:42 +1000 Subject: [PATCH 0027/4300] docs/library/index: Update docs after umodule rename. - Update guide for extending built-in modules. - Remove any last trace of umodule in other docs. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- docs/esp32/tutorial/pwm.rst | 4 +- docs/library/index.rst | 68 +++++++++++-------- docs/library/zephyr.DiskAccess.rst | 2 +- docs/library/zephyr.FlashArea.rst | 2 +- docs/renesas-ra/tutorial/using_peripheral.rst | 5 +- docs/zephyr/quickref.rst | 2 +- 6 files changed, 47 insertions(+), 36 deletions(-) diff --git a/docs/esp32/tutorial/pwm.rst b/docs/esp32/tutorial/pwm.rst index 12d10a86b94..2650284d35f 100644 --- a/docs/esp32/tutorial/pwm.rst +++ b/docs/esp32/tutorial/pwm.rst @@ -50,7 +50,7 @@ low all of the time. * Example of a smooth frequency change:: - from utime import sleep + from time import sleep from machine import Pin, PWM F_MIN = 500 @@ -75,7 +75,7 @@ low all of the time. * Example of a smooth duty change:: - from utime import sleep + from time import sleep from machine import Pin, PWM DUTY_MAX = 2**16 - 1 diff --git a/docs/library/index.rst b/docs/library/index.rst index 985a7ad770d..e428f3a062d 100644 --- a/docs/library/index.rst +++ b/docs/library/index.rst @@ -191,34 +191,27 @@ The following libraries are specific to the Zephyr port. Extending built-in libraries from Python ---------------------------------------- -Many built-in modules are actually named ``umodule`` rather than ``module``, but -MicroPython will alias any module prefixed with a ``u`` to the non-``u`` -version. This means that, for example, ``import time`` will first attempt to -resolve from the filesystem, and then failing that will fall back to the -built-in ``utime``. On the other hand, ``import utime`` will always go directly -to the built-in. +A subset of the built-in modules are able to be extended by Python code by +providing a module of the same name in the filesystem. This extensibility +applies to the following Python standard library modules which are built-in to +the firmware: ``array``, ``binascii``, ``collections``, ``errno``, ``hashlib``, +``heapq``, ``io``, ``json``, ``os``, ``platform``, ``random``, ``re``, +``select``, ``socket``, ``ssl``, ``struct``, ``time`` ``zlib``, as well as the +MicroPython-specific ``machine`` module. All other built-in modules cannot be +extended from the filesystem. This allows the user to provide an extended implementation of a built-in library (perhaps to provide additional CPython compatibility or missing functionality). -The user-provided module (in ``module.py``) can still use the built-in -functionality by importing ``umodule`` directly (e.g. typically an extension -module ``time.py`` will do ``from utime import *``). This is used extensively -in :term:`micropython-lib`. See :ref:`packages` for more information. - -This extensibility applies to the following Python standard library modules -which are built-in to the firmware: ``array``, ``binascii``, ``collections``, -``errno``, ``hashlib``, ``heapq``, ``io``, ``json``, ``os``, ``platform``, -``random``, ``re``, ``select``, ``socket``, ``ssl``, ``struct``, ``sys``, -``time``, ``zlib``, as well as the MicroPython-specific libraries: ``bluepy``, -``bluetooth``, ``machine``, ``timeq``, ``websocket``. All other built-in -modules cannot be extended from the filesystem. - -*Other than when you specifically want to force the use of the built-in module, -we recommend always using* ``import module`` *rather than* ``import umodule``. - -**Note:** In MicroPython v1.21.0 and higher, it is now possible to force an -import of the built-in module by clearing ``sys.path`` during the import. For -example, in ``time.py``, you can write:: +This is used extensively in :term:`micropython-lib`, see :ref:`packages` for +more information. The filesystem module will typically do a wildcard import of +the built-in module in order to inherit all the globals (classes, functions and +variables) from the built-in. + +In MicroPython v1.21.0 and higher, to prevent the filesystem module from +importing itself, it can force an import of the built-in module it by +temporarily clearing ``sys.path`` during the import. For example, to extend the +``time`` module from Python, a file named ``time.py`` on the filesystem would +do the following:: _path = sys.path sys.path = () @@ -228,6 +221,25 @@ example, in ``time.py``, you can write:: sys.path = _path del _path -This is now the preferred way (instead of ``from utime import *``), as the -``u``-prefix will be removed from the names of built-in modules in a future -version of MicroPython. + def extra_method(): + pass + +The result is that ``time.py`` contains all the globals of the built-in ``time`` +module, but adds ``extra_method``. + +In earlier versions of MicroPython, you can force an import of a built-in module +by appending a ``u`` to the start of its name. For example, ``import utime`` +instead of ``import time``. For example, ``time.py`` on the filesystem could +look like:: + + from utime import * + + def extra_method(): + pass + +This way is still supported, but the ``sys.path`` method described above is now +preferred as the ``u``-prefix will be removed from the names of built-in +modules in a future version of MicroPython. + +*Other than when it specifically needs to force the use of the built-in module, +code should always use* ``import module`` *rather than* ``import umodule``. diff --git a/docs/library/zephyr.DiskAccess.rst b/docs/library/zephyr.DiskAccess.rst index d19d81a962e..3e5fa9a3575 100644 --- a/docs/library/zephyr.DiskAccess.rst +++ b/docs/library/zephyr.DiskAccess.rst @@ -34,5 +34,5 @@ Methods These methods implement the simple and extended :ref:`block protocol ` defined by - :class:`uos.AbstractBlockDev`. + :class:`os.AbstractBlockDev`. diff --git a/docs/library/zephyr.FlashArea.rst b/docs/library/zephyr.FlashArea.rst index 306347d449e..9cd4dd59d68 100644 --- a/docs/library/zephyr.FlashArea.rst +++ b/docs/library/zephyr.FlashArea.rst @@ -37,4 +37,4 @@ Methods These methods implement the simple and extended :ref:`block protocol ` defined by - :class:`uos.AbstractBlockDev`. + :class:`os.AbstractBlockDev`. diff --git a/docs/renesas-ra/tutorial/using_peripheral.rst b/docs/renesas-ra/tutorial/using_peripheral.rst index c50181b3d68..7296d8b3304 100644 --- a/docs/renesas-ra/tutorial/using_peripheral.rst +++ b/docs/renesas-ra/tutorial/using_peripheral.rst @@ -12,9 +12,8 @@ To list supported modules, please enter:: help('modules') -Especially `machine` module and class :ref:`machine.Pin ` are very important for using -peripherals. Note that prefix 'u' is added to the module for MicroPython, -so you can see "umachine" in the list but you can use it like "import machine". +Especially `machine` module and class :ref:`machine.Pin ` are very +important for using peripherals. Using "from machine import Pin", Pin name is available corresponding to the RA MCU's pin name which are Pin.cpu.P000 and 'P000'. diff --git a/docs/zephyr/quickref.rst b/docs/zephyr/quickref.rst index 329a9c41c0c..57262ffb5c6 100644 --- a/docs/zephyr/quickref.rst +++ b/docs/zephyr/quickref.rst @@ -19,7 +19,7 @@ See the corresponding section of the tutorial: :ref:`intro`. Delay and timing ---------------- -Use the :mod:`time ` module:: +Use the :mod:`time