Skip to content

Commit

Permalink
Make display code more robust (#15)
Browse files Browse the repository at this point in the history
Make display code more robust
  • Loading branch information
eyurtsev authored May 12, 2023
1 parent e5330b9 commit a489293
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kork/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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

Expand Down

0 comments on commit a489293

Please sign in to comment.