Skip to content

Commit

Permalink
To achieve correct operation on a STM32 µProcessor, I ad to disable t…
Browse files Browse the repository at this point in the history
…wo tests.

The first one used sys.float_info (not available in µPython), the second one used
collection.Hashable (also not available ib µPython).
Now the packing and unpacking seems to work on STM32.
  • Loading branch information
Wojciech Zabołotny authored and Wojciech Zabołotny committed Jul 18, 2021
1 parent 414b84b commit 0aecb03
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions umsgpack.py
Expand Up @@ -766,9 +766,10 @@ def _unpack_map(code, fp, options):
if isinstance(k, list):
# Attempt to convert list into a hashable tuple
k = _deep_list_to_tuple(k)
elif not isinstance(k, collections.Hashable):
raise UnhashableKeyException(
"encountered unhashable key: %s, %s" % (str(k), str(type(k))))
# The test below does not work in MicroPython
#elif not isinstance(k, collections.Hashable):
# raise UnhashableKeyException(
# "encountered unhashable key: %s, %s" % (str(k), str(type(k))))
elif k in d:
raise DuplicateKeyException(
"encountered duplicate key: %s, %s" % (str(k), str(type(k))))
Expand Down Expand Up @@ -989,11 +990,11 @@ def __init():
compatibility = False

# Auto-detect system float precision
if sys.float_info.mant_dig == 53:
_float_precision = "double"
else:
_float_precision = "single"

#if sys.float_info.mant_dig == 53:
# _float_precision = "double"
#else:
# _float_precision = "single"
_float_precision = "double"
# Map packb and unpackb to the appropriate version
if sys.version_info[0] == 3:
pack = _pack3
Expand Down

0 comments on commit 0aecb03

Please sign in to comment.