Author: Maciej Fijalkowski <fij...@gmail.com> Branch: Changeset: r47569:af517c41faff Date: 2011-09-23 19:45 +0200 http://bitbucket.org/pypy/pypy/changeset/af517c41faff/
Log: merge default diff --git a/pypy/interpreter/pyparser/future.py b/pypy/interpreter/pyparser/future.py --- a/pypy/interpreter/pyparser/future.py +++ b/pypy/interpreter/pyparser/future.py @@ -225,14 +225,16 @@ raise DoneException self.consume_whitespace() - def consume_whitespace(self): + def consume_whitespace(self, newline_ok=False): while 1: c = self.getc() if c in whitespace: self.pos += 1 continue - elif c == '\\': - self.pos += 1 + elif c == '\\' or newline_ok: + slash = c == '\\' + if slash: + self.pos += 1 c = self.getc() if c == '\n': self.pos += 1 @@ -243,8 +245,10 @@ if self.getc() == '\n': self.pos += 1 self.atbol() + elif slash: + raise DoneException else: - raise DoneException + return else: return @@ -281,7 +285,7 @@ return else: self.pos += 1 - self.consume_whitespace() + self.consume_whitespace(paren_list) if paren_list and self.getc() == ')': self.pos += 1 return # Handles trailing comma inside parenthesis diff --git a/pypy/interpreter/pyparser/test/test_futureautomaton.py b/pypy/interpreter/pyparser/test/test_futureautomaton.py --- a/pypy/interpreter/pyparser/test/test_futureautomaton.py +++ b/pypy/interpreter/pyparser/test/test_futureautomaton.py @@ -3,7 +3,7 @@ from pypy.tool import stdlib___future__ as fut def run(s): - f = future.FutureAutomaton(future.futureFlags_2_5, s) + f = future.FutureAutomaton(future.futureFlags_2_7, s) try: f.start() except future.DoneException: @@ -113,6 +113,14 @@ assert f.lineno == 1 assert f.col_offset == 0 +def test_paren_with_newline(): + s = 'from __future__ import (division,\nabsolute_import)\n' + f = run(s) + assert f.pos == len(s) + assert f.flags == (fut.CO_FUTURE_DIVISION | fut.CO_FUTURE_ABSOLUTE_IMPORT) + assert f.lineno == 1 + assert f.col_offset == 0 + def test_multiline(): s = '"abc" #def\n #ghi\nfrom __future__ import (division as b, generators,)\nfrom __future__ import with_statement\n' f = run(s) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit