2020-12-07 18:16:16 -05:00
|
|
|
try:
|
2023-08-22 11:15:46 -04:00
|
|
|
from io import BytesIO
|
|
|
|
import msgpack
|
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
2020-12-07 18:16:16 -05:00
|
|
|
|
|
|
|
b = BytesIO()
|
|
|
|
msgpack.pack(False, s)
|
|
|
|
print(b.getvalue())
|
|
|
|
|
|
|
|
b = BytesIO()
|
|
|
|
msgpack.pack({"a": (-1, 0, 2, [3, None], 128)}, b)
|
|
|
|
print(b.getvalue())
|
|
|
|
|
|
|
|
# pack to a small-int not allowed
|
|
|
|
try:
|
|
|
|
msgpack.pack(123, 1)
|
2021-03-15 09:57:36 -04:00
|
|
|
except (AttributeError, OSError): # CPython and uPy have different errors
|
|
|
|
print("Exception")
|
2020-12-07 18:16:16 -05:00
|
|
|
|
|
|
|
# pack to an object not allowed
|
|
|
|
try:
|
|
|
|
msgpack.pack(123, {})
|
2021-03-15 09:57:36 -04:00
|
|
|
except (AttributeError, OSError): # CPython and uPy have different errors
|
|
|
|
print("Exception")
|