diff options
| author | Tom McDermott <spon@wattwatchers.com.au> | 2019-08-05 21:09:14 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-07-06 14:59:50 +1000 |
| commit | c1f74b300548912f92edb4ae004dc486e0b7c8bf (patch) | |
| tree | 55ba0f0a20dbe7f7c9021ca1d95db2f3b5716081 /tests | |
| parent | d934f8c8a8bb896595a6b976126222b438f383ea (diff) | |
docs/library: Warn that ustruct doesn't handle spaces in format strings.
And also add a test to capture the CPython difference.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cpydiff/modules_struct_whitespace_in_format.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/cpydiff/modules_struct_whitespace_in_format.py b/tests/cpydiff/modules_struct_whitespace_in_format.py new file mode 100644 index 000000000..dd0f8b48f --- /dev/null +++ b/tests/cpydiff/modules_struct_whitespace_in_format.py @@ -0,0 +1,13 @@ +""" +categories: Modules,struct +description: Struct pack with whitespace in format, whitespace ignored by CPython, error on uPy +cause: MicroPython is optimised for code size. +workaround: Don't use spaces in format strings. +""" +import struct + +try: + print(struct.pack('b b', 1, 2)) + print('Should have worked') +except: + print('struct.error') |
