(core) Error explanations from friendly-traceback

Summary: Extend formula error messages with explanations from https://github.com/friendly-traceback/friendly-traceback. Only for Python 3.

Test Plan: Updated several Python tests. In general, these require separate branches for Python 2 and 3.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3542
This commit is contained in:
Alex Hall
2022-08-11 13:03:45 +02:00
parent 31f54065f5
commit 49cb51bac5
11 changed files with 239 additions and 64 deletions

View File

@@ -208,18 +208,9 @@ def _is_special_table(table_id):
def exec_module_text(module_text):
mod = imp.new_module(codebuilder.code_filename)
codebuilder.save_to_linecache(module_text)
code_obj = compile(module_text, codebuilder.code_filename, "exec")
# pylint: disable=exec-used
filename = "usercode"
mod = imp.new_module(filename)
# Ensure that source lines show in tracebacks
linecache.cache[filename] = (
len(module_text),
None,
[line + '\n' for line in module_text.splitlines()],
filename,
)
code_obj = compile(module_text, filename, "exec")
exec(code_obj, mod.__dict__)
return mod