From f77fd6257cc14ff9a05d702406501a49b7bacbd0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 12 May 2025 17:39:16 +0200 Subject: [PATCH] tests/cpydiff: Document format separator difference. Signed-off-by: Jeff Epler --- tests/cpydiff/types_str_formatsep.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/cpydiff/types_str_formatsep.py 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")