Skip to content

Commit

Permalink
diagnostic.Engine: rename print_diagnostic→render_diagnostic; always …
Browse files Browse the repository at this point in the history
…call it.
whitequark committed Jan 4, 2016
1 parent 2c5cf10 commit 8bdc7ba
Showing 3 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pythonparser/diagnostic.py
Original file line number Diff line number Diff line change
@@ -151,11 +151,10 @@ def process(self, diagnostic):
The default implementation of :meth:`process` renders non-fatal
diagnostics to ``sys.stderr``, and raises fatal ones as a :class:`Error`.
"""
self.render_diagnostic(diagnostic)
if diagnostic.level == "fatal" or \
(self.all_errors_are_fatal and diagnostic.level == "error"):
raise Error(diagnostic)
else:
self.print_diagnostic(diagnostic)

def print_diagnostic(self, diagnostic):
def render_diagnostic(self, diagnostic):
sys.stderr.write("\n".join(diagnostic.render()) + "\n")
1 change: 1 addition & 0 deletions pythonparser/test/test_lexer.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ def assertLexesVersions(self, input, versions, *expected_tokens, **kwargs):
tokens = expected_tokens
self.buffer = source.Buffer(input)
self.engine = diagnostic.Engine(all_errors_are_fatal=True)
self.engine.render_diagnostic = lambda diag: None
self.lexer = lexer.Lexer(self.buffer, version, self.engine, **kwargs)
for token in self.lexer:
if len(tokens) < 2:
1 change: 1 addition & 0 deletions pythonparser/test/test_parser.py
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ def parser_for(self, code, version, interactive=False):

self.source_buffer = source.Buffer(code, str(version))
self.engine = diagnostic.Engine()
self.engine.render_diagnostic = lambda diag: None
self.lexer = lexer.Lexer(self.source_buffer, version, self.engine,
interactive=interactive)

0 comments on commit 8bdc7ba

Please sign in to comment.