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

And also add a test to capture the CPython difference.
pull/7498/head
Tom McDermott 2019-08-05 21:09:14 +10:00 zatwierdzone przez Damien George
rodzic d934f8c8a8
commit c1f74b3005
2 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

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

Wyświetl plik

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