Showing with 3,456 additions and 1,376 deletions.
  1. +7 −1 .github/workflows/build.yml
  2. +1 −1 README.rst
  3. +2 −0 lib/oofatfs/ff.c
  4. +4 −1 lib/oofatfs/ffconf.h
  5. +1 −1 lib/tinyusb
  6. +59 −35 lib/utils/pyexec.c
  7. +4 −0 lib/utils/pyexec.h
  8. +30 −13 locale/ID.po
  9. +32 −14 locale/circuitpython.pot
  10. +30 −13 locale/cs.po
  11. +43 −17 locale/de_DE.po
  12. +30 −13 locale/el.po
  13. +30 −13 locale/en_GB.po
  14. +39 −13 locale/es.po
  15. +30 −13 locale/fil.po
  16. +37 −14 locale/fr.po
  17. +30 −13 locale/hi.po
  18. +30 −13 locale/it_IT.po
  19. +30 −13 locale/ja.po
  20. +30 −13 locale/ko.po
  21. +30 −13 locale/nl.po
  22. +30 −13 locale/pl.po
  23. +40 −14 locale/pt_BR.po
  24. +41 −15 locale/sv.po
  25. +39 −13 locale/zh_Latn_pinyin.po
  26. +23 −0 main.c
  27. +6 −0 ports/atmel-samd/Makefile
  28. +110 −88 ports/atmel-samd/audio_dma.c
  29. +10 −6 ports/atmel-samd/audio_dma.h
  30. +1 −0 ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.h
  31. +1 −0 ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk
  32. +13 −0 ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h
  33. +8 −0 ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.h
  34. +8 −0 ports/atmel-samd/boards/arduino_zero/mpconfigboard.h
  35. +1 −0 ports/atmel-samd/boards/blm_badge/mpconfigboard.mk
  36. +1 −1 ports/atmel-samd/boards/cp_sapling_m0_revb/pins.c
  37. +21 −0 ports/atmel-samd/boards/datum_distance/mpconfigboard.h
  38. +19 −0 ports/atmel-samd/boards/datum_imu/mpconfigboard.h
  39. +21 −0 ports/atmel-samd/boards/datum_light/mpconfigboard.h
  40. +21 −0 ports/atmel-samd/boards/datum_weather/mpconfigboard.h
  41. +0 −5 ports/atmel-samd/boards/dynossat_edu_obc/mpconfigboard.h
  42. +18 −0 ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
  43. +21 −0 ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h
  44. +0 −1 ports/atmel-samd/boards/hallowing_m0_express/board.c
  45. +0 −1 ports/atmel-samd/boards/hallowing_m4_express/board.c
  46. +2 −0 ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h
  47. +1 −0 ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
  48. +0 −1 ports/atmel-samd/boards/monster_m4sk/board.c
  49. +0 −1 ports/atmel-samd/boards/pewpew_m4/board.c
  50. +0 −1 ports/atmel-samd/boards/pybadge/board.c
  51. +0 −1 ports/atmel-samd/boards/pygamer/board.c
  52. +0 −1 ports/atmel-samd/boards/pyportal/board.c
  53. +0 −1 ports/atmel-samd/boards/pyportal_titano/board.c
  54. +0 −1 ports/atmel-samd/boards/seeeduino_wio_terminal/board.c
  55. +4 −0 ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.h
  56. +3 −1 ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk
  57. +0 −1 ports/atmel-samd/boards/ugame10/board.c
  58. +3 −3 ports/atmel-samd/common-hal/audioio/AudioOut.c
  59. +7 −0 ports/atmel-samd/common-hal/busio/I2C.c
  60. +7 −0 ports/atmel-samd/common-hal/canio/Listener.c
  61. +6 −0 ports/atmel-samd/common-hal/pulseio/PulseIn.c
  62. +4 −45 ports/atmel-samd/common-hal/pwmio/PWMOut.c
  63. +1 −0 ports/atmel-samd/common-hal/rgbmatrix/RGBMatrix.c
  64. +7 −0 ports/atmel-samd/mpconfigport.h
  65. +1 −1 ports/atmel-samd/peripherals
  66. +84 −0 ports/atmel-samd/shared_timers.c
  67. +9 −6 ports/{cxd56/common-hal/busio/OneWire.h → atmel-samd/shared_timers.h}
  68. +126 −68 ports/atmel-samd/supervisor/port.c
  69. +0 −4 ports/atmel-samd/timer_handler.h
  70. +2 −1 ports/cxd56/common-hal/busio/SPI.c
  71. +0 −1 ports/esp32s2/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c
  72. +0 −1 ports/esp32s2/boards/adafruit_funhouse/board.c
  73. +2 −2 ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h
  74. +52 −0 ports/esp32s2/boards/ai_thinker_esp_12k_nodemcu/board.c
  75. +11 −10 shared-module/busio/OneWire.h → ports/esp32s2/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h
  76. +17 −0 ports/esp32s2/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.mk
  77. +48 −0 ports/esp32s2/boards/ai_thinker_esp_12k_nodemcu/pins.c
  78. +33 −0 ports/esp32s2/boards/ai_thinker_esp_12k_nodemcu/sdkconfig
  79. +52 −0 ports/esp32s2/boards/crumpspace_crumps2/board.c
  80. +8 −6 ports/{atmel-samd/common-hal/busio/OneWire.h → esp32s2/boards/crumpspace_crumps2/mpconfigboard.h}
  81. +22 −0 ports/esp32s2/boards/crumpspace_crumps2/mpconfigboard.mk
  82. +53 −0 ports/esp32s2/boards/crumpspace_crumps2/pins.c
  83. +39 −0 ports/esp32s2/boards/crumpspace_crumps2/sdkconfig
  84. +0 −1 ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/board.c
  85. +0 −2 ports/esp32s2/boards/microdev_micro_s2/mpconfigboard.h
  86. +226 −0 ports/esp32s2/boards/morpheans_morphesp-240/board.c
  87. +44 −0 ports/esp32s2/boards/morpheans_morphesp-240/mpconfigboard.h
  88. +17 −0 ports/esp32s2/boards/morpheans_morphesp-240/mpconfigboard.mk
  89. +58 −0 ports/esp32s2/boards/morpheans_morphesp-240/pins.c
  90. +6 −0 ports/esp32s2/boards/morpheans_morphesp-240/sdkconfig
  91. +19 −6 ports/{mimxrt10xx/common-hal/busio/OneWire.h → esp32s2/boards/odt_pixelwing_esp32_s2/board.c}
  92. +41 −0 ports/esp32s2/boards/odt_pixelwing_esp32_s2/mpconfigboard.h
  93. +17 −0 ports/esp32s2/boards/odt_pixelwing_esp32_s2/mpconfigboard.mk
  94. +15 −0 ports/esp32s2/boards/odt_pixelwing_esp32_s2/pins.c
  95. +39 −0 ports/esp32s2/boards/odt_pixelwing_esp32_s2/sdkconfig
  96. +5 −0 ports/esp32s2/common-hal/canio/Listener.c
  97. +4 −1 ports/esp32s2/supervisor/port.c
  98. +3 −1 ports/mimxrt10xx/Makefile
  99. +0 −1 ports/mimxrt10xx/linking/common.ld
  100. +11 −5 ports/mimxrt10xx/supervisor/port.c
  101. +0 −1 ports/nrf/boards/clue_nrf52840_express/board.c
  102. +0 −1 ports/nrf/boards/hiibot_bluefi/board.c
  103. +0 −1 ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c
  104. +0 −1 ports/nrf/boards/ohs2020_badge/board.c
  105. +3 −5 ports/nrf/boards/particle_argon/mpconfigboard.h
  106. +3 −5 ports/nrf/boards/particle_boron/mpconfigboard.h
  107. +2 −0 ports/nrf/boards/pca10100/mpconfigboard.h
  108. +1 −0 ports/nrf/boards/pca10100/mpconfigboard.mk
  109. +2 −0 ports/nrf/boards/simmel/mpconfigboard.h
  110. +2 −12 ports/nrf/common-hal/busio/SPI.c
  111. +9 −7 ports/nrf/supervisor/port.c
  112. +1 −1 ports/raspberrypi/audio_dma.c
  113. +7 −7 ports/raspberrypi/audio_dma.h
  114. +0 −1 ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c
  115. +1 −1 ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c
  116. +12 −5 ports/raspberrypi/{common-hal/busio/OneWire.h → boards/pimoroni_interstate75/board.c}
  117. +10 −0 ports/raspberrypi/boards/pimoroni_interstate75/mpconfigboard.h
  118. +11 −0 ports/raspberrypi/boards/pimoroni_interstate75/mpconfigboard.mk
  119. +1 −0 ports/raspberrypi/boards/pimoroni_interstate75/pico-sdk-configboard.h
  120. +52 −0 ports/raspberrypi/boards/pimoroni_interstate75/pins.c
  121. +0 −31 ports/raspberrypi/boards/pimoroni_keybow2040/mpconfigboard.h
  122. +0 −5 ports/raspberrypi/boards/pimoroni_picolipo_16mb/mpconfigboard.h
  123. +0 −5 ports/raspberrypi/boards/pimoroni_picolipo_4mb/mpconfigboard.h
  124. +0 −35 ports/raspberrypi/boards/pimoroni_picosystem/mpconfigboard.h
  125. +13 −6 ports/{esp32s2/common-hal/busio/OneWire.h → raspberrypi/boards/pimoroni_plasma2040/board.c}
  126. +10 −0 ports/raspberrypi/boards/pimoroni_plasma2040/mpconfigboard.h
  127. +11 −0 ports/raspberrypi/boards/pimoroni_plasma2040/mpconfigboard.mk
  128. +1 −0 ports/raspberrypi/boards/pimoroni_plasma2040/pico-sdk-configboard.h
  129. +41 −0 ports/raspberrypi/boards/pimoroni_plasma2040/pins.c
  130. +0 −18 ports/raspberrypi/boards/pimoroni_tiny2040/mpconfigboard.h
  131. +0 −4 ports/raspberrypi/boards/pimoroni_tiny2040/pins.c
  132. +4 −3 ports/raspberrypi/common-hal/busio/I2C.c
  133. +2 −3 ports/raspberrypi/supervisor/port.c
  134. +2 −0 ports/stm/boards/espruino_pico/mpconfigboard.h
  135. +0 −1 ports/stm/boards/meowbit_v121/board.c
  136. +2 −0 ports/stm/boards/pyb_nano_v2/mpconfigboard.h
  137. +1 −0 ports/stm/boards/pyb_nano_v2/mpconfigboard.mk
  138. +2 −0 ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.h
  139. +3 −0 ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk
  140. +2 −0 ports/stm/boards/stm32f411ve_discovery/mpconfigboard.h
  141. +1 −0 ports/stm/boards/stm32f411ve_discovery/mpconfigboard.mk
  142. +2 −0 ports/stm/boards/thunderpack_v11/mpconfigboard.h
  143. +7 −0 ports/stm/common-hal/canio/Listener.c
  144. +8 −2 ports/stm/supervisor/port.c
  145. +1 −1 ports/unix/mpconfigport.h
  146. +1 −1 py/argcheck.c
  147. +14 −7 py/circuitpy_defns.mk
  148. +27 −7 py/circuitpy_mpconfig.h
  149. +17 −5 py/circuitpy_mpconfig.mk
  150. +14 −14 py/modmicropython.c
  151. +2 −0 py/mpstate.h
  152. +0 −3 py/objmodule.c
  153. +13 −5 py/objstrunicode.c
  154. +2 −1 py/runtime.c
  155. +1 −0 requirements-dev.txt
  156. +2 −2 shared-bindings/_bleio/Adapter.c
  157. +93 −0 shared-bindings/atexit/__init__.c
  158. +0 −172 shared-bindings/bitbangio/OneWire.c
  159. +4 −2 shared-bindings/bitbangio/__init__.c
  160. +63 −0 shared-bindings/bitmaptools/__init__.c
  161. +4 −0 shared-bindings/bitmaptools/__init__.h
  162. +0 −43 shared-bindings/busio/OneWire.h
  163. +1 −1 shared-bindings/busio/SPI.c
  164. +1 −1 shared-bindings/busio/SPI.h
  165. +19 −0 shared-bindings/busio/UART.c
  166. +4 −2 shared-bindings/busio/__init__.c
  167. +1 −1 shared-bindings/canio/__init__.c
  168. +5 −6 shared-bindings/displayio/Display.c
  169. +1 −1 shared-bindings/displayio/Display.h
  170. +3 −1 shared-bindings/displayio/EPaperDisplay.c
  171. +1 −1 shared-bindings/displayio/Group.c
  172. +1 −1 shared-bindings/keypad/EventQueue.c
  173. +2 −0 shared-bindings/keypad/KeyMatrix.c
  174. +1 −0 shared-bindings/keypad/Keys.c
  175. +39 −0 shared-bindings/microcontroller/Pin.c
  176. +2 −0 shared-bindings/microcontroller/Pin.h
  177. +43 −47 shared-bindings/{busio → onewireio}/OneWire.c
  178. +11 −11 shared-bindings/{bitbangio → onewireio}/OneWire.h
  179. +53 −0 shared-bindings/onewireio/__init__.c
  180. +6 −5 ports/nrf/common-hal/busio/OneWire.h → shared-bindings/onewireio/__init__.h
  181. +8 −0 shared-bindings/storage/__init__.c
  182. +2 −2 shared-bindings/traceback/__init__.c
  183. +136 −64 shared-bindings/usb_hid/Device.c
  184. +4 −2 shared-bindings/usb_hid/Device.h
  185. +1 −1 shared-bindings/usb_hid/__init__.c
  186. +92 −0 shared-module/atexit/__init__.c
  187. +46 −0 shared-module/atexit/__init__.h
  188. +7 −4 shared-module/audiomp3/MP3Decoder.c
  189. +139 −1 shared-module/bitmaptools/__init__.c
  190. +0 −59 shared-module/busio/OneWire.c
  191. +1 −1 shared-module/displayio/Display.c
  192. +2 −9 shared-module/displayio/__init__.c
  193. +8 −8 shared-module/{bitbangio → onewireio}/OneWire.c
  194. +4 −4 shared-module/{bitbangio → onewireio}/OneWire.h
  195. +1 −7 ports/stm/common-hal/busio/OneWire.h → shared-module/onewireio/__init__.c
  196. +136 −79 shared-module/usb_hid/Device.c
  197. +11 −6 shared-module/usb_hid/Device.h
  198. +24 −32 shared-module/usb_hid/__init__.c
  199. +1 −1 shared-module/usb_hid/__init__.h
  200. +6 −0 supervisor/background_callback.h
  201. +5 −1 supervisor/shared/background_callback.c
  202. +2 −2 supervisor/shared/bluetooth/bluetooth.c
  203. +1 −1 supervisor/shared/usb/usb.c
  204. +22 −0 tests/circuitpython/atexit_test.py
  205. +0 −21 tests/misc/sys_atexit.py
  206. +0 −2 tests/misc/sys_atexit.py.exp
  207. +1 −2 tests/unicode/unicode.py
  208. +8 −0 tests/unicode/unicode_repr.py
  209. +4 −4 tests/unix/extra_coverage.py.exp
  210. +1 −1 tools/adabot
  211. +10 −0 tools/codeformat.py
  212. +1 −2 tools/fonts/ter-u12n.bdf
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,13 @@ jobs:
- "pewpew10"
- "pewpew_m4"
- "picoplanet"
- "pimoroni_interstate75"
- "pimoroni_keybow2040"
- "pimoroni_pga2040"
- "pimoroni_picolipo_16mb"
- "pimoroni_picolipo_4mb"
- "pimoroni_picosystem"
- "pimoroni_plasma2040"
- "pimoroni_tiny2040"
- "pitaya_go"
- "pyb_nano_v2"
Expand Down Expand Up @@ -462,7 +464,7 @@ jobs:
- name: Install deps
run: |
sudo apt-get install -y gettext
pip install requests sh click setuptools awscli
pip install -r requirements-dev.txt
wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
sudo tar -C /usr --strip-components=1 -xaf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
- name: Versions
Expand Down Expand Up @@ -502,8 +504,10 @@ jobs:
- "adafruit_funhouse"
- "adafruit_magtag_2.9_grayscale"
- "adafruit_metro_esp32s2"
- "ai_thinker_esp_12k_nodemcu"
- "artisense_rd00"
- "atmegazero_esp32s2"
- "crumpspace_crumps2"
- "electroniccats_bastwifi"
- "espressif_kaluga_1"
- "espressif_kaluga_1.3"
Expand All @@ -517,8 +521,10 @@ jobs:
- "gravitech_cucumber_rs"
- "lilygo_ttgo_t8_s2_st7789"
- "microdev_micro_s2"
- "morpheans_morphesp-240"
- "muselab_nanoesp32_s2_wroom"
- "muselab_nanoesp32_s2_wrover"
- "odt_pixelwing_esp32_s2"
- "targett_module_clip_wroom"
- "targett_module_clip_wrover"
- "unexpectedmaker_feathers2"
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ besides a text editor (we recommend `Mu <https://codewith.mu/>`_ for beginners.)
Starting with CircuitPython 7.0.0, some boards may only be connectable over Bluetooth Low Energy
(BLE). Those boards provide serial and file access over BLE instead of USB using open protocols.
(Some boards may use both USB and BLE.) BLE access can be done from a variety of apps including
`code.circuitpythonn.org <https://code.circuitpython.org>`_.
`code.circuitpython.org <https://code.circuitpython.org>`_.

CircuitPython features unified Python core APIs and a growing list of 300+ device libraries and
drivers that work with it. These libraries also work on single board computers with regular
Expand Down
2 changes: 2 additions & 0 deletions lib/oofatfs/ff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ static DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x7FF
break;
}
}
MP_FALLTHROUGH
/* go to default */
#endif
default:
Expand Down Expand Up @@ -5518,6 +5519,7 @@ FRESULT f_mkfs (
}
st = 1; /* Do not compress short run */
/* go to next case */
MP_FALLTHROUGH
case 1:
ch = si++; /* Fill the short run */
if (--j == 0) st = 0;
Expand Down
5 changes: 4 additions & 1 deletion lib/oofatfs/ffconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@
/ memory for the working buffer, memory management functions, ff_memalloc() and
/ ff_memfree() in ffsystem.c, need to be added to the project. */


#ifdef MICROPY_FATFS_LFN_UNICODE
#define FF_LFN_UNICODE (MICROPY_FATFS_LFN_UNICODE)
#else
#define FF_LFN_UNICODE 0
#endif
/* This option switches the character encoding on the API when LFN is enabled.
/
/ 0: ANSI/OEM in current CP (TCHAR = char)
Expand Down
2 changes: 1 addition & 1 deletion lib/tinyusb
Submodule tinyusb updated 104 files
94 changes: 59 additions & 35 deletions lib/utils/pyexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#include "lib/utils/pyexec.h"
#include "genhdr/mpversion.h"

#if CIRCUITPY_ATEXIT
#include "shared-module/atexit/__init__.h"
#endif

pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL;
int pyexec_system_exit = 0;

Expand All @@ -58,6 +62,7 @@ STATIC bool repl_display_debugging_info = 0;
#define EXEC_FLAG_SOURCE_IS_VSTR (16)
#define EXEC_FLAG_SOURCE_IS_FILENAME (32)
#define EXEC_FLAG_SOURCE_IS_READER (64)
#define EXEC_FLAG_SOURCE_IS_ATEXIT (128)

// parses, compiles and executes the code in the lexer
// frees the lexer before returning
Expand All @@ -81,52 +86,65 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
nlr.ret_val = NULL;
if (nlr_push(&nlr) == 0) {
mp_obj_t module_fun;
#if MICROPY_MODULE_FROZEN_MPY
if (exec_flags & EXEC_FLAG_SOURCE_IS_RAW_CODE) {
// source is a raw_code object, create the function
module_fun = mp_make_function_from_raw_code(source, MP_OBJ_NULL, MP_OBJ_NULL);
} else
#if CIRCUITPY_ATEXIT
if (!(exec_flags & EXEC_FLAG_SOURCE_IS_ATEXIT))
#endif
{
#if MICROPY_ENABLE_COMPILER
mp_lexer_t *lex;
if (exec_flags & EXEC_FLAG_SOURCE_IS_VSTR) {
const vstr_t *vstr = source;
lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, vstr->buf, vstr->len, 0);
} else if (exec_flags & EXEC_FLAG_SOURCE_IS_READER) {
lex = mp_lexer_new(MP_QSTR__lt_stdin_gt_, *(mp_reader_t *)source);
} else if (exec_flags & EXEC_FLAG_SOURCE_IS_FILENAME) {
lex = mp_lexer_new_from_file(source);
} else {
lex = (mp_lexer_t *)source;
#if MICROPY_MODULE_FROZEN_MPY
if (exec_flags & EXEC_FLAG_SOURCE_IS_RAW_CODE) {
// source is a raw_code object, create the function
module_fun = mp_make_function_from_raw_code(source, MP_OBJ_NULL, MP_OBJ_NULL);
} else
#endif
{
#if MICROPY_ENABLE_COMPILER
mp_lexer_t *lex;
if (exec_flags & EXEC_FLAG_SOURCE_IS_VSTR) {
const vstr_t *vstr = source;
lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, vstr->buf, vstr->len, 0);
} else if (exec_flags & EXEC_FLAG_SOURCE_IS_READER) {
lex = mp_lexer_new(MP_QSTR__lt_stdin_gt_, *(mp_reader_t *)source);
} else if (exec_flags & EXEC_FLAG_SOURCE_IS_FILENAME) {
lex = mp_lexer_new_from_file(source);
} else {
lex = (mp_lexer_t *)source;
}
// source is a lexer, parse and compile the script
qstr source_name = lex->source_name;
if (input_kind == MP_PARSE_FILE_INPUT) {
mp_store_global(MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
}
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
module_fun = mp_compile(&parse_tree, source_name, exec_flags & EXEC_FLAG_IS_REPL);
// Clear the parse tree because it has a heap pointer we don't need anymore.
*((uint32_t volatile *)&parse_tree.chunk) = 0;
#else
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("script compilation not supported"));
#endif
}
// source is a lexer, parse and compile the script
qstr source_name = lex->source_name;

// If the code was loaded from a file it's likely to be running for a while so we'll long
// live it and collect any garbage before running.
if (input_kind == MP_PARSE_FILE_INPUT) {
mp_store_global(MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
module_fun = make_obj_long_lived(module_fun, 6);
gc_collect();
}
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
module_fun = mp_compile(&parse_tree, source_name, exec_flags & EXEC_FLAG_IS_REPL);
// Clear the parse tree because it has a heap pointer we don't need anymore.
*((uint32_t volatile *)&parse_tree.chunk) = 0;
#else
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("script compilation not supported"));
#endif
}

// If the code was loaded from a file it's likely to be running for a while so we'll long
// live it and collect any garbage before running.
if (input_kind == MP_PARSE_FILE_INPUT) {
module_fun = make_obj_long_lived(module_fun, 6);
gc_collect();
}

// execute code
mp_hal_set_interrupt_char(CHAR_CTRL_C); // allow ctrl-C to interrupt us
#if MICROPY_REPL_INFO
start = mp_hal_ticks_ms();
#endif
mp_call_function_0(module_fun);
#if CIRCUITPY_ATEXIT
if (exec_flags & EXEC_FLAG_SOURCE_IS_ATEXIT) {
atexit_callback_t *callback = (atexit_callback_t *)source;
mp_call_function_n_kw(callback->func, callback->n_pos, callback->n_kw, callback->args);
} else
#endif
{
mp_call_function_0(module_fun);
}
mp_hal_set_interrupt_char(-1); // disable interrupt
mp_handle_pending(true); // handle any pending exceptions (and any callbacks)
nlr_pop();
Expand All @@ -149,7 +167,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
mp_hal_stdout_tx_strn("\x04", 1);
}
// check for SystemExit
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
// at the moment, the value of SystemExit is unused
ret = pyexec_system_exit;
#if CIRCUITPY_ALARM
Expand Down Expand Up @@ -746,6 +764,12 @@ int pyexec_frozen_module(const char *name, pyexec_result_t *result) {
}
#endif

#if CIRCUITPY_ATEXIT
int pyexec_exit_handler(const void *source, pyexec_result_t *result) {
return parse_compile_execute(source, MP_PARSE_FILE_INPUT, EXEC_FLAG_SOURCE_IS_ATEXIT, result);
}
#endif

#if MICROPY_REPL_INFO
mp_obj_t pyb_set_repl_info(mp_obj_t o_value) {
repl_display_debugging_info = mp_obj_get_int(o_value);
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/pyexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ void pyexec_event_repl_init(void);
int pyexec_event_repl_process_char(int c);
extern uint8_t pyexec_repl_active;

#if CIRCUITPY_ATEXIT
int pyexec_exit_handler(const void *source, pyexec_result_t *result);
#endif

#if MICROPY_REPL_INFO
mp_obj_t pyb_set_repl_info(mp_obj_t o_value);
MP_DECLARE_CONST_FUN_OBJ_1(pyb_set_repl_info_obj);
Expand Down
43 changes: 30 additions & 13 deletions locale/ID.po
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ msgid ""
"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d"
msgstr ""

#: shared-bindings/microcontroller/Pin.c
msgid "%q and %q contain duplicate pins"
msgstr ""

#: shared-bindings/microcontroller/Pin.c
msgid "%q contains duplicate pins"
msgstr ""

#: ports/atmel-samd/common-hal/sdioio/SDCard.c
msgid "%q failure: %d"
msgstr "%q gagal: %d"
Expand All @@ -98,6 +106,10 @@ msgstr "indeks %q harus bilangan bulat, bukan %s"
msgid "%q length must be %q"
msgstr ""

#: shared-bindings/usb_hid/Device.c
msgid "%q length must be >= 1"
msgstr ""

#: shared-bindings/vectorio/Polygon.c
msgid "%q list must be a list"
msgstr "daftar %q harus berupa daftar"
Expand All @@ -110,14 +122,6 @@ msgstr ""
msgid "%q must be %d-%d"
msgstr ""

#: shared-bindings/usb_hid/Device.c
msgid "%q must be 0-255"
msgstr ""

#: shared-bindings/usb_hid/Device.c
msgid "%q must be 1-255"
msgstr ""

#: py/argcheck.c
msgid "%q must be >= %d"
msgstr ""
Expand All @@ -134,10 +138,6 @@ msgstr "%q harus >= 0"
msgid "%q must be >= 1"
msgstr "%q harus >= 1"

#: shared-bindings/usb_hid/Device.c
msgid "%q must be None or between 1 and len(report_descriptor)-1"
msgstr ""

#: py/argcheck.c
msgid "%q must be a string"
msgstr ""
Expand Down Expand Up @@ -175,6 +175,10 @@ msgstr "%q harus berupa int"
msgid "%q() takes %d positional arguments but %d were given"
msgstr "%q() mengambil posisi argumen %d tapi %d yang diberikan"

#: shared-bindings/usb_hid/Device.c
msgid "%q, %q, and %q must all be the same length"
msgstr ""

#: ports/esp32s2/bindings/espidf/__init__.c ports/esp32s2/esp_error.c
#, c-format
msgid "%s error 0x%x"
Expand Down Expand Up @@ -500,6 +504,10 @@ msgstr ""
msgid "Attempted heap allocation when VM not running."
msgstr ""

#: ports/raspberrypi/audio_dma.c
msgid "Audio conversion not implemented"
msgstr ""

#: shared-bindings/wifi/Radio.c
msgid "AuthMode.OPEN is not used with password"
msgstr ""
Expand Down Expand Up @@ -1237,6 +1245,10 @@ msgstr "Otentikasi tidak cukup"
msgid "Insufficient encryption"
msgstr "Enkripsi tidak cukup"

#: ports/raspberrypi/audio_dma.c
msgid "Internal audio buffer too small"
msgstr ""

#: ports/stm/common-hal/busio/UART.c
msgid "Internal define error"
msgstr "Kesalahan definisi internal"
Expand All @@ -1246,7 +1258,7 @@ msgstr "Kesalahan definisi internal"
msgid "Internal error #%d"
msgstr "Kesalahan internal #%d"

#: shared-bindings/sdioio/SDCard.c
#: shared-bindings/sdioio/SDCard.c shared-module/usb_hid/Device.c
msgid "Invalid %q"
msgstr ""

Expand Down Expand Up @@ -1530,6 +1542,11 @@ msgstr ""
msgid "Missing jmp_pin. Instruction %d jumps on pin"
msgstr ""

#: shared-module/usb_hid/Device.c
#, c-format
msgid "More than %d report ids not supported"
msgstr ""

#: shared-bindings/busio/UART.c shared-bindings/displayio/Group.c
msgid "Must be a %q subclass."
msgstr "Harus berupa subclass %q."
Expand Down
Loading