diff --git a/mathics/format/form/outputform.py b/mathics/format/form/outputform.py index 8f67b34ce..f9f514d0e 100644 --- a/mathics/format/form/outputform.py +++ b/mathics/format/form/outputform.py @@ -265,12 +265,12 @@ def render_output_form(expr: BaseElement, evaluation: Evaluation, **kwargs): callback = _default_render_output_form try: result = callback(format_expr, evaluation, **kwargs) - return result - except _WrongFormattedExpression: + except Exception: # If the key is not present, or the execution fails for any reason, use # the default - pass - return _default_render_output_form(format_expr, evaluation, **kwargs) + return _default_render_output_form(format_expr, evaluation, **kwargs) + else: + return result @register_outputform("System`Format") diff --git a/test/builtin/string/test_operations.py b/test/builtin/string/test_operations.py index 45dafbc10..c96c1e007 100644 --- a/test/builtin/string/test_operations.py +++ b/test/builtin/string/test_operations.py @@ -43,6 +43,13 @@ "StringTake[]", "StringTake argument checking", ), + ( + 'xx = "a string"; StringTake[xx[0]]', + ("StringTake called with 1 argument; 2 arguments are expected.",), + "StringTake[a string[0]]", + "StringTake bug in formatting", + ), + ("Clear[xx]", None, None, None), ], ) def test_string_take(str_expr, msgs, str_expected, fail_msg):