all: Replace legacy name with MicroPython and MPy as applicable.
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled

With the aim of getting consistency, and removing the need to learn an
additional term, replace uses of uPy/uPython with MPy/MicroPython.

Rule of thumb was to use "MPy" abbreviation where "CPy" is used nearby, but
the full word MicroPython otherwise.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton
2025-09-24 11:17:51 +10:00
committed by Damien George
parent fb2b638ba0
commit 3ec8b9a77c
61 changed files with 74 additions and 77 deletions

View File

@@ -2,7 +2,7 @@
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
# MicroPython allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types

View File

@@ -2,7 +2,7 @@
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
# MicroPython allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types

View File

@@ -2,7 +2,7 @@
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
# MicroPython allows normal generators to be awaitables
coroutine = lambda f: f
else:
import types

View File

@@ -1,6 +1,6 @@
# tests basics of bound methods
# uPy and CPython differ when printing a bound method, so just print the type
# MicroPython and CPython differ when printing a bound method, so just print the type
print(type(repr([].append)))

View File

@@ -54,7 +54,7 @@ print(range(1, 100, 5)[15:5:3])
print(range(1, 100, -5)[5:15:-3])
print(range(1, 100, -5)[15:5:3])
# for this case uPy gives a different stop value but the listed elements are still correct
# for this case MicroPython gives a different stop value but the listed elements are still correct
print(list(range(7, -2, -4)[2:-2:]))
# zero step

View File

@@ -21,5 +21,5 @@ except TypeError:
try:
setattr(int, 'to_bytes', 1)
except (AttributeError, TypeError):
# uPy raises AttributeError, CPython raises TypeError
# MicroPython raises AttributeError, CPython raises TypeError
print('AttributeError/TypeError')

View File

@@ -52,7 +52,7 @@ print(C.f7(12))
print(C.f8(13))
print(C.f9(14))
# not working in uPy
# not working in MicroPython
#class C(list):
# # this acts like a method and binds self
# f1 = list.extend

View File

@@ -35,5 +35,5 @@ except AttributeError:
try:
del int.to_bytes
except (AttributeError, TypeError):
# uPy raises AttributeError, CPython raises TypeError
# MicroPython raises AttributeError, CPython raises TypeError
print('AttributeError/TypeError')

View File

@@ -14,7 +14,7 @@ except NameError:
try:
do_del()
except: # NameError:
# FIXME uPy returns KeyError for this
# FIXME MicroPython returns KeyError for this
print("NameError")
# delete globals using a list

View File

@@ -10,7 +10,7 @@ except NameError:
try:
del x
except: # NameError:
# FIXME uPy returns KeyError for this
# FIXME MicroPython returns KeyError for this
print("NameError")
class C:

View File

@@ -8,5 +8,5 @@ except NameError:
# "Instances of set are compared to instances of frozenset based on their
# members. For example:"
print(set('abc') == frozenset('abc'))
# This doesn't work in uPy
# This doesn't work in MicroPython
#print(set('abc') in set([frozenset('abc')]))

View File

@@ -16,7 +16,7 @@ except AttributeError:
print('SKIP')
raise SystemExit
# __name__ of a bound native method is not implemented in uPy
# __name__ of a bound native method is not implemented in MicroPython
# the test here is to make sure it doesn't crash
try:
str((1).to_bytes.__name__)

View File

@@ -15,13 +15,13 @@ print(gc.isenabled())
gc.collect()
if hasattr(gc, 'mem_free'):
# uPy has these extra functions
# MicroPython has these extra functions
# just test they execute and return an int
assert type(gc.mem_free()) is int
assert type(gc.mem_alloc()) is int
if hasattr(gc, 'threshold'):
# uPy has this extra function
# MicroPython has this extra function
# check execution and returns
assert(gc.threshold(1) is None)
assert(gc.threshold() == 0)

View File

@@ -9,7 +9,7 @@ except (AttributeError, ImportError):
class MyIO(io.IOBase):
def write(self, buf):
# CPython and uPy pass in different types for buf (str vs bytearray)
# CPython and MicroPython pass in different types for buf (str vs bytearray)
print('write', len(buf))
return len(buf)

View File

@@ -10,7 +10,7 @@ except IndexError:
else:
raise AssertionError("No IndexError raised")
# popping such that list storage shrinks (tests implementation detail of uPy)
# popping such that list storage shrinks (tests implementation detail of MicroPython)
l = list(range(20))
for i in range(len(l)):
l.pop()

View File

@@ -1,4 +1,4 @@
# uPy behaviour only: builtin modules are read-only
# MicroPython behaviour only: builtin modules are read-only
import sys
try:
sys.x = 1

View File

@@ -7,7 +7,7 @@ except NameError:
raise SystemExit
# completely empty string
# uPy and CPy differ for this case
# MPy and CPy differ for this case
#try:
# compile("", "stdin", "single")
#except SyntaxError:

View File

@@ -28,7 +28,7 @@ test_syntax("() = []") # can't assign to empty tuple (in 3.6 we can)
test_syntax("del ()") # can't delete empty tuple (in 3.6 we can)
# from basics/sys1.py
# uPy prints version 3.4
# MicroPython prints version 3.4
import sys
print(sys.version[:3])
print(sys.version_info[0], sys.version_info[1])

View File

@@ -86,7 +86,7 @@ test_syntax("yield")
test_syntax("nonlocal a")
test_syntax("await 1")
# error on uPy, warning on CPy
# error on MPy, warning on CPy
#test_syntax("def f():\n a = 1\n global a")
# default except must be last
@@ -98,7 +98,7 @@ test_syntax("f(1=2)")
# non-keyword after keyword
test_syntax("f(a=1, 2)")
# doesn't error on uPy but should
# doesn't error on MPy but should
#test_syntax("f(1, i for i in i)")
# all elements of dict/set must be pairs or singles

View File

@@ -30,7 +30,7 @@ def print_exc(e):
if l.startswith(" File "):
l = l.split('"')
print(l[0], l[2])
# uPy and CPy tracebacks differ in that CPy prints a source line for
# MPy and CPy tracebacks differ in that CPy prints a source line for
# each traceback entry. In this case, we know that offending line
# has 4-space indent, so filter it out.
elif not l.startswith(" "):

View File

@@ -17,7 +17,7 @@ print(x + (10, 100, 10000))
x += (10, 11, 12)
print(x)
# construction of tuple from large iterator (tests implementation detail of uPy)
# construction of tuple from large iterator (tests implementation detail of MicroPython)
print(tuple(range(20)))
# unsupported unary operation

View File

@@ -1,6 +1,6 @@
"""
categories: Modules,struct
description: Struct pack with too few args, not checked by uPy
description: Struct pack with too few args, not checked by MicroPython
cause: Unknown
workaround: Unknown
"""

View File

@@ -1,6 +1,6 @@
"""
categories: Modules,struct
description: Struct pack with too many args, not checked by uPy
description: Struct pack with too many args, not checked by MicroPython
cause: Unknown
workaround: Unknown
"""

View File

@@ -1,6 +1,6 @@
"""
categories: Modules,struct
description: Struct pack with whitespace in format, whitespace ignored by CPython, error on uPy
description: Struct pack with whitespace in format, whitespace ignored by CPython, error on MicroPython
cause: MicroPython is optimised for code size.
workaround: Don't use spaces in format strings.
"""

View File

@@ -1,6 +1,6 @@
"""
categories: Types,float
description: uPy allows implicit conversion of objects in maths operations while CPython does not.
description: MicroPython allows implicit conversion of objects in maths operations while CPython does not.
cause: Unknown
workaround: Objects should be wrapped in ``float(obj)`` for compatibility with CPython.
"""

View File

@@ -12,7 +12,7 @@ def custom_handler(loop, context):
async def task(i):
# Raise with 2 args so exception prints the same in uPy and CPython
# Raise with 2 args so exception prints the same in MicroPython and CPython
raise ValueError(i, i + 1)

View File

@@ -1,8 +1,7 @@
try:
import hashlib
except ImportError:
# This is neither uPy, nor cPy, so must be uPy with
# hashlib module disabled.
# MicroPython with hashlib module disabled.
print("SKIP")
raise SystemExit

View File

@@ -1,8 +1,7 @@
try:
import hashlib
except ImportError:
# This is neither uPy, nor cPy, so must be uPy with
# hashlib module disabled.
# MicroPython with hashlib module disabled.
print("SKIP")
raise SystemExit

View File

@@ -1,8 +1,7 @@
try:
import hashlib
except ImportError:
# This is neither uPy, nor cPy, so must be uPy with
# hashlib module disabled.
# MicroPython with hashlib module disabled.
print("SKIP")
raise SystemExit

View File

@@ -16,11 +16,11 @@ print(s.getvalue())
# dump to a small-int not allowed
try:
json.dump(123, 1)
except (AttributeError, OSError): # CPython and uPy have different errors
except (AttributeError, OSError): # CPython and MicroPython have different errors
print("Exception")
# dump to an object not allowed
try:
json.dump(123, {})
except (AttributeError, OSError): # CPython and uPy have different errors
except (AttributeError, OSError): # CPython and MicroPython have different errors
print("Exception")

View File

@@ -18,7 +18,7 @@ class S(io.IOBase):
def write(self, buf):
if type(buf) == bytearray:
# uPy passes a bytearray, CPython passes a str
# MicroPython passes a bytearray, CPython passes a str
buf = str(buf, "ascii")
self.buf += buf
return len(buf)

View File

@@ -25,20 +25,20 @@ for sep in [
# dump to a small-int not allowed
try:
json.dump(123, 1, separators=sep)
except (AttributeError, OSError): # CPython and uPy have different errors
except (AttributeError, OSError): # CPython and MicroPython have different errors
print("Exception")
# dump to an object not allowed
try:
json.dump(123, {}, separators=sep)
except (AttributeError, OSError): # CPython and uPy have different errors
except (AttributeError, OSError): # CPython and MicroPython have different errors
print("Exception")
try:
s = StringIO()
json.dump(False, s, separators={"a": 1})
except (TypeError, ValueError): # CPython and uPy have different errors
except (TypeError, ValueError): # CPython and MicroPython have different errors
print("Exception")
# invalid separator types

View File

@@ -1,4 +1,4 @@
# test uPy json behaviour that's not valid in CPy
# test MicroPython json behaviour that's not valid in CPython
try:
import json

View File

@@ -39,7 +39,7 @@ for sep in [
try:
json.dumps(False, separators={"a": 1})
except (TypeError, ValueError): # CPython and uPy have different errors
except (TypeError, ValueError): # CPython and MicroPython have different errors
print("Exception")
# invalid separator types

View File

@@ -11,7 +11,7 @@ def test_re(r):
try:
re.compile(r)
print("OK")
except: # uPy and CPy use different errors, so just ignore the type
except: # MPy and CPy use different errors, so just ignore the type
print("Error")

View File

@@ -61,7 +61,7 @@ try:
except:
print("invalid group")
# invalid group with very large number (to test overflow in uPy)
# invalid group with very large number (to test overflow in MicroPython)
try:
re.sub("(a)", "b\\199999999999999999999999999999999999999", "a")
except:

View File

@@ -144,7 +144,7 @@ if full_tests:
for alignment in ("", "<", ">", "=", "^"):
for fill in ("", " ", "0", "@"):
for sign in ("", "+", "-", " "):
# An empty precision defaults to 6, but when uPy is
# An empty precision defaults to 6, but when MicroPython is
# configured to use a float, we can only use a
# precision of 6 with numbers less than 10 and still
# get results that compare to CPython (which uses
@@ -164,7 +164,7 @@ if full_tests:
for alignment in ("", "<", ">", "=", "^"):
for fill in ("", " ", "0", "@"):
for sign in ("", "+", "-", " "):
# An empty precision defaults to 6, but when uPy is
# An empty precision defaults to 6, but when MicroPython is
# configured to use a float, we can only use a
# precision of 6 with numbers less than 10 and still
# get results that compare to CPython (which uses

View File

@@ -6,7 +6,7 @@ print("%i" % 1.0)
print("%u" % 1.0)
# these 3 have different behaviour in Python 3.x versions
# uPy raises a TypeError, following Python 3.5 (earlier versions don't)
# MicroPython raises a TypeError, following Python 3.5 (earlier versions don't)
# print("%x" % 18.0)
# print("%o" % 18.0)
# print("%X" % 18.0)

Binary file not shown.

View File

@@ -1,4 +1,4 @@
print("uPy")
print("interned")
print("a long string that is not interned")
print("a string that has unicode αβγ chars")
print(b"bytes 1234\x01")

View File

@@ -13,5 +13,5 @@ print("test", file=sys.stdout)
try:
print(file=1)
except (AttributeError, OSError): # CPython and uPy differ in error message
except (AttributeError, OSError): # CPython and MicroPython differ in error message
print("Error")

View File

@@ -30,5 +30,5 @@ f.close()
try:
f.seek(1)
except (OSError, ValueError):
# CPy raises ValueError, uPy raises OSError
# CPy raises ValueError, MPy raises OSError
print("OSError or ValueError")

View File

@@ -1,4 +1,4 @@
# test syntax errors for uPy-specific decorators
# test syntax errors for MicroPython-specific decorators
def test_syntax(code):

View File

@@ -34,7 +34,7 @@ test()
buf = io.StringIO()
sys.print_exception(global_exc, buf)
for l in buf.getvalue().split("\n"):
# uPy on pyboard prints <stdin> as file, so remove filename.
# MicroPython on pyboard prints <stdin> as file, so remove filename.
if l.startswith(" File "):
l = l.split('"')
print(l[0], l[2])

View File

@@ -39,7 +39,7 @@ try:
except NotImplementedError:
print("NotImplementedError")
# uPy raises TypeError, should be ValueError
# MicroPython raises TypeError, should be ValueError
try:
"%c" % b"\x01\x02"
except (TypeError, ValueError):
@@ -99,10 +99,10 @@ try:
except NotImplementedError:
print("NotImplementedError")
# struct pack with too many args, not checked by uPy
# struct pack with too many args, not checked by MicroPython
print(struct.pack("bb", 1, 2, 3))
# struct pack with too few args, not checked by uPy
# struct pack with too few args, not checked by MicroPython
print(struct.pack("bb", 1))
# array slice assignment with unsupported RHS

View File

@@ -11,7 +11,7 @@ def test(code):
print("NotImplementedError")
# uPy requires spaces between literal numbers and keywords, CPy doesn't
# MPy requires spaces between literal numbers and keywords, CPy doesn't
try:
eval("1and 0")
except SyntaxError:

View File

@@ -20,11 +20,11 @@ def print_exc(e):
print_exception(e, buf)
s = buf.getvalue()
for l in s.split("\n"):
# uPy on pyboard prints <stdin> as file, so remove filename.
# MPy on pyboard prints <stdin> as file, so remove filename.
if l.startswith(" File "):
l = l.split('"')
print(l[0], l[2])
# uPy and CPy tracebacks differ in that CPy prints a source line for
# MPy and CPy tracebacks differ in that CPy prints a source line for
# each traceback entry. In this case, we know that offending line
# has 4-space indent, so filter it out.
elif not l.startswith(" "):
@@ -89,7 +89,7 @@ try:
except Exception as e:
print_exc(e)
# Test non-stream object passed as output object, only valid for uPy
# Test non-stream object passed as output object, only valid for MicroPython
if hasattr(sys, "print_exception"):
try:
sys.print_exception(Exception, 1)

View File

@@ -128,7 +128,7 @@ from frzqstr import returns_NULL
print(returns_NULL())
# test for freeze_mpy
# test for freeze_mpy (importing prints several lines)
import frozentest
print(frozentest.__file__)

View File

@@ -250,7 +250,7 @@ b'\x00\xff'
frzmpy4 1
frzmpy4 2
NULL
uPy
interned
a long string that is not interned
a string that has unicode αβγ chars
b'bytes 1234\x01'