diff options
Diffstat (limited to 'ports/stm32/make-stmconst.py')
-rw-r--r-- | ports/stm32/make-stmconst.py | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/ports/stm32/make-stmconst.py b/ports/stm32/make-stmconst.py index 4ef6143bd..ff84977ad 100644 --- a/ports/stm32/make-stmconst.py +++ b/ports/stm32/make-stmconst.py @@ -9,25 +9,13 @@ from __future__ import print_function import argparse import re -# Python 2/3 compatibility -import platform -if platform.python_version_tuple()[0] == "2": - - def convert_bytes_to_str(b): - return b - -elif platform.python_version_tuple()[0] == "3": - - def convert_bytes_to_str(b): - try: - return str(b, "utf8") - except ValueError: - # some files have invalid utf8 bytes, so filter them out - return "".join(chr(l) for l in b if l <= 126) - - -# end compatibility code +def convert_bytes_to_str(b): + try: + return str(b, "utf8") + except ValueError: + # some files have invalid utf8 bytes, so filter them out + return "".join(chr(l) for l in b if l <= 126) # given a list of (name,regex) pairs, find the first one that matches the given line |