fix: Python wrapper catches BaseException instead of Exception (#2902)

This commit is contained in:
Guillaume Bouvignies
2023-12-21 10:26:13 +01:00
committed by GitHub
parent 0ed5da1ab1
commit ecdb381f6b
@@ -261,7 +261,7 @@ try:
res_json = re.sub(replace_nan, ' null ', json.dumps(res, separators=(',', ':'), default=str).replace('\n', ''))
with open("result.json", 'w') as f:
f.write(res_json)
except Exception as e:
except BaseException as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
tb = traceback.format_tb(exc_traceback)
with open("result.json", 'w') as f:
@@ -926,7 +926,7 @@ for line in sys.stdin:
res[k] = to_b_64(v)
res_json = re.sub(replace_nan, ' null ', json.dumps(res, separators=(',', ':'), default=str).replace('\n', ''))
sys.stdout.write("wm_res:" + res_json + "\n")
except Exception as e:
except BaseException as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
tb = traceback.format_tb(exc_traceback)
err_json = json.dumps({{ "error": {{ "message": str(e), "name": e.__class__.__name__, "stack": '\n'.join(tb[1:]) }} }}, separators=(',', ':'), default=str).replace('\n', '')