Skip to content

Commit 40ad8f1

Browse files
stinosdpgeorge
authored andcommitted
all: Rename "sys" module to "usys".
This is consistent with the other 'micro' modules and allows implementing additional features in Python via e.g. micropython-lib's sys. Note this is a breaking change (not backwards compatible) for ports which do not enable weak links, as "import sys" must now be replaced with "import usys".
1 parent b0932fc commit 40ad8f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+142
-89
lines changed

docs/library/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ it will fallback to loading the built-in ``ujson`` module.
7777
cmath.rst
7878
gc.rst
7979
math.rst
80-
sys.rst
8180
uarray.rst
8281
uasyncio.rst
8382
ubinascii.rst
@@ -93,6 +92,7 @@ it will fallback to loading the built-in ``ujson`` module.
9392
usocket.rst
9493
ussl.rst
9594
ustruct.rst
95+
usys.rst
9696
utime.rst
9797
uzlib.rst
9898
_thread.rst

docs/library/sys.rst renamed to docs/library/usys.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
:mod:`sys` -- system specific functions
2-
=======================================
1+
:mod:`usys` -- system specific functions
2+
========================================
33

4-
.. module:: sys
4+
.. module:: usys
55
:synopsis: system specific functions
66

77
|see_cpython_module| :mod:`python:sys`.
@@ -28,10 +28,10 @@ Functions
2828
This function is a MicroPython extension intended to provide similar
2929
functionality to the :mod:`atexit` module in CPython.
3030

31-
.. function:: print_exception(exc, file=sys.stdout, /)
31+
.. function:: print_exception(exc, file=usys.stdout, /)
3232

3333
Print exception with a traceback to a file-like object *file* (or
34-
`sys.stdout` by default).
34+
`usys.stdout` by default).
3535

3636
.. admonition:: Difference to CPython
3737
:class: attention
@@ -84,7 +84,7 @@ Constants
8484
value directly, but instead count number of bits in it::
8585

8686
bits = 0
87-
v = sys.maxsize
87+
v = usys.maxsize
8888
while v:
8989
bits += 1
9090
v >>= 1
@@ -113,7 +113,7 @@ Constants
113113
is an identifier of a board, e.g. ``"pyboard"`` for the original MicroPython
114114
reference board. It thus can be used to distinguish one board from another.
115115
If you need to check whether your program runs on MicroPython (vs other
116-
Python implementation), use `sys.implementation` instead.
116+
Python implementation), use `usys.implementation` instead.
117117

118118
.. data:: stderr
119119

drivers/nrf24l01/nrf24l01test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Test for nrf24l01 module. Portable between MicroPython targets."""
22

3-
import sys
3+
import usys
44
import ustruct as struct
55
import utime
66
from machine import Pin, SPI
@@ -14,14 +14,14 @@
1414
# master may be a slow device. Value tested with Pyboard, ESP32 and ESP8266.
1515
_SLAVE_SEND_DELAY = const(10)
1616

17-
if sys.platform == "pyboard":
17+
if usys.platform == "pyboard":
1818
cfg = {"spi": 2, "miso": "Y7", "mosi": "Y8", "sck": "Y6", "csn": "Y5", "ce": "Y4"}
19-
elif sys.platform == "esp8266": # Hardware SPI
19+
elif usys.platform == "esp8266": # Hardware SPI
2020
cfg = {"spi": 1, "miso": 12, "mosi": 13, "sck": 14, "csn": 4, "ce": 5}
21-
elif sys.platform == "esp32": # Software SPI
21+
elif usys.platform == "esp32": # Software SPI
2222
cfg = {"spi": -1, "miso": 32, "mosi": 33, "sck": 25, "csn": 26, "ce": 27}
2323
else:
24-
raise ValueError("Unsupported platform {}".format(sys.platform))
24+
raise ValueError("Unsupported platform {}".format(usys.platform))
2525

2626
# Addresses are in little-endian format. They correspond to big-endian
2727
# 0xf0f0f0f0e1, 0xf0f0f0f0d2

extmod/webrepl/websocket_helper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import sys
1+
try:
2+
import usys as sys
3+
except ImportError:
4+
import sys
25

36
try:
47
import ubinascii as binascii

py/objmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
159159
#endif
160160
#endif
161161
#if MICROPY_PY_SYS
162-
{ MP_ROM_QSTR(MP_QSTR_sys), MP_ROM_PTR(&mp_module_sys) },
162+
{ MP_ROM_QSTR(MP_QSTR_usys), MP_ROM_PTR(&mp_module_sys) },
163163
#endif
164164
#if MICROPY_PY_GC && MICROPY_ENABLE_GC
165165
{ MP_ROM_QSTR(MP_QSTR_gc), MP_ROM_PTR(&mp_module_gc) },

tests/basics/async_await2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# test await expression
22

3-
import sys
3+
try:
4+
import usys as sys
5+
except ImportError:
6+
import sys
47
if sys.implementation.name == 'micropython':
58
# uPy allows normal generators to be awaitables
69
coroutine = lambda f: f

tests/basics/async_for2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# test waiting within "async for" __anext__ function
22

3-
import sys
3+
try:
4+
import usys as sys
5+
except ImportError:
6+
import sys
47
if sys.implementation.name == 'micropython':
58
# uPy allows normal generators to be awaitables
69
coroutine = lambda f: f

tests/basics/async_with2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# test waiting within async with enter/exit functions
22

3-
import sys
3+
try:
4+
import usys as sys
5+
except ImportError:
6+
import sys
47
if sys.implementation.name == 'micropython':
58
# uPy allows normal generators to be awaitables
69
coroutine = lambda f: f

tests/basics/attrtuple1.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# test attrtuple
22
# we can't test this type directly so we use sys.implementation object
33

4-
import sys
4+
try:
5+
import usys as sys
6+
except ImportError:
7+
import sys
58
t = sys.implementation
69

710
# It can be just a normal tuple on small ports

tests/basics/builtin_callable.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
print(callable("dfsd"))
88

99
# modules should not be callabe
10-
import sys
10+
try:
11+
import usys as sys
12+
except ImportError:
13+
import sys
1114
print(callable(sys))
1215

1316
# builtins should be callable

0 commit comments

Comments
 (0)