From 2b32dce25660c960915edbfd4178e6f5444e1a6c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 17 Feb 2022 08:36:29 -0600 Subject: [PATCH 1/2] genlast: Actually catch errors when preprocessing files Due to a number of problems, an error calling the preprocessor wasn't making the whole genlast process fail. Now, after an execption during preprocess is printed, it is re-raised. Then, by actually collating the results of executor.map, the exception will be raised in the main thread context. Any CalledProcessError is simply converted to a nonzero exit status. --- py/genlast.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/py/genlast.py b/py/genlast.py index 0071c7b8497c..ad44745d973a 100644 --- a/py/genlast.py +++ b/py/genlast.py @@ -48,6 +48,7 @@ def preprocess(command, output_dir, fn): process_file(fn, output_dir, output) except Exception as e: print(e, file=sys.stderr) + raise def maybe_preprocess(command, output_dir, fn): @@ -72,6 +73,18 @@ def maybe_preprocess(command, output_dir, fn): # Mac and Windows use 'spawn'. Uncomment this during testing to catch spawn-specific problems on Linux. # multiprocessing.set_start_method("spawn") executor = ProcessPoolExecutor(max_workers=multiprocessing.cpu_count() + 1) - executor.map(maybe_preprocess, itertools.repeat(command), itertools.repeat(output_dir), check) - executor.map(preprocess, itertools.repeat(command), itertools.repeat(output_dir), always) + results = [] + try: + results.extend( + executor.map( + maybe_preprocess, itertools.repeat(command), itertools.repeat(output_dir), check + ) + ) + results.extend( + executor.map( + preprocess, itertools.repeat(command), itertools.repeat(output_dir), always + ) + ) + except subprocess.CalledProcessError: + raise SystemExit(1) executor.shutdown() From 1309ef083bd69ade9308aea3b25540d6f62ccaa1 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 17 Feb 2022 08:38:02 -0600 Subject: [PATCH 2/2] translate: Can't use compress_max_length_bits during qstr generation --- supervisor/shared/translate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/supervisor/shared/translate.c b/supervisor/shared/translate.c index 674df7579a71..fefda4600646 100644 --- a/supervisor/shared/translate.c +++ b/supervisor/shared/translate.c @@ -87,11 +87,13 @@ STATIC int put_utf8(char *buf, int u) { } uint16_t decompress_length(const compressed_string_t *compressed) { + #ifndef NO_QSTR #if (compress_max_length_bits <= 8) return 1 + (compressed->data >> (8 - compress_max_length_bits)); #else return 1 + ((compressed->data * 256 + compressed->tail[0]) >> (16 - compress_max_length_bits)); #endif + #endif } char *decompress(const compressed_string_t *compressed, char *decompressed) {