diff --git a/kork/display.py b/kork/display.py index 60381ce..74749f3 100644 --- a/kork/display.py +++ b/kork/display.py @@ -42,8 +42,6 @@ class HtmlResult(TypedDict): class _NoExpectedAnswer: """A sentinel class to indicate that there is no expected answer.""" - pass - NO_EXPECTED_ANSWER = _NoExpectedAnswer() @@ -61,7 +59,12 @@ def as_html_dict( code = code_result["code"].strip() if pretty_print: - code = AstPrinter().visit(parse(code), pretty_print=True) + try: + code = AstPrinter().visit(parse(code), pretty_print=True) + except Exception: + # This is display code. Broad exception handling OK for now + # we can make the code more robust later. + code = code else: code = code