Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: pyparser-improvements-3
Changeset: r94319:2b67feca9fbd
Date: 2018-04-14 11:20 +0200
http://bitbucket.org/pypy/pypy/changeset/2b67feca9fbd/
Log: less code in except block
diff --git a/pypy/interpreter/pyparser/pyparse.py
b/pypy/interpreter/pyparser/pyparse.py
--- a/pypy/interpreter/pyparser/pyparse.py
+++ b/pypy/interpreter/pyparser/pyparse.py
@@ -153,26 +153,27 @@
# which is expected to work independently of them. It's
# certainly the case for all futures in Python <= 2.7.
tokens = pytokenizer.generate_tokens(source_lines, flags)
-
- newflags, last_future_import = (
- future.add_future_flags(self.future_flags, tokens))
- compile_info.last_future_import = last_future_import
- compile_info.flags |= newflags
-
- if compile_info.flags & consts.CO_FUTURE_PRINT_FUNCTION:
- self.grammar = pygram.python_grammar_no_print
- else:
- self.grammar = pygram.python_grammar
-
- for token in tokens:
- if self.add_token(token):
- break
except error.TokenError as e:
e.filename = compile_info.filename
raise
except error.TokenIndentationError as e:
e.filename = compile_info.filename
raise
+
+ newflags, last_future_import = (
+ future.add_future_flags(self.future_flags, tokens))
+ compile_info.last_future_import = last_future_import
+ compile_info.flags |= newflags
+
+ if compile_info.flags & consts.CO_FUTURE_PRINT_FUNCTION:
+ self.grammar = pygram.python_grammar_no_print
+ else:
+ self.grammar = pygram.python_grammar
+
+ try:
+ for token in tokens:
+ if self.add_token(token):
+ break
except parser.ParseError as e:
# Catch parse errors, pretty them up and reraise them as a
# SyntaxError.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit