summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2025-05-12 17:39:16 +0200
committerDamien George <damien@micropython.org>2025-05-13 12:19:46 +1000
commitf77fd6257cc14ff9a05d702406501a49b7bacbd0 (patch)
tree626138364fc3587ebb605fd947f47400b3a9eb9e /tests
parent9032491efd8a63e0b13dbcfb8579cde4791c03af (diff)
tests/cpydiff: Document format separator difference.
Signed-off-by: Jeff Epler <jepler@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/cpydiff/types_str_formatsep.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/cpydiff/types_str_formatsep.py b/tests/cpydiff/types_str_formatsep.py
new file mode 100644
index 000000000..05d0b8d3d
--- /dev/null
+++ b/tests/cpydiff/types_str_formatsep.py
@@ -0,0 +1,19 @@
+"""
+categories: Types,str
+description: MicroPython accepts the "," grouping option with any radix, unlike CPython
+cause: To reduce code size, MicroPython does not issue an error for this combination
+workaround: Do not use a format string like ``{:,b}`` if CPython compatibility is required.
+"""
+
+try:
+ print("{:,b}".format(99))
+except ValueError:
+ print("ValueError")
+try:
+ print("{:,x}".format(99))
+except ValueError:
+ print("ValueError")
+try:
+ print("{:,o}".format(99))
+except ValueError:
+ print("ValueError")