docs/library: Warn that ustruct doesn't handle spaces in format strings.

And also add a test to capture the CPython difference.
This commit is contained in:
Tom McDermott 2019-08-05 21:09:14 +10:00 committed by Damien George
parent d934f8c8a8
commit c1f74b3005
2 changed files with 18 additions and 0 deletions

View File

@ -12,6 +12,11 @@ Supported format codes: ``b``, ``B``, ``h``, ``H``, ``i``, ``I``, ``l``,
``L``, ``q``, ``Q``, ``s``, ``P``, ``f``, ``d`` (the latter 2 depending
on the floating-point support).
.. admonition:: Difference to CPython
:class: attention
Whitespace is not supported in format strings.
Functions
---------

View File

@ -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')