[pypy-svn] r68727 - in pypy/trunk/pypy: interpreter/pyparser module/__builtin__/test
benjamin at codespeak.net
benjamin at codespeak.net
Sat Oct 24 16:35:40 CEST 2009
Author: benjamin
Date: Sat Oct 24 16:35:39 2009
New Revision: 68727
Modified:
pypy/trunk/pypy/interpreter/pyparser/future.py
pypy/trunk/pypy/module/__builtin__/test/test_builtin.py
Log:
convince __future__ statements with no ending newlines to work
Modified: pypy/trunk/pypy/interpreter/pyparser/future.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyparser/future.py (original)
+++ pypy/trunk/pypy/interpreter/pyparser/future.py Sat Oct 24 16:35:39 2009
@@ -240,13 +240,19 @@
if self.getc() not in letters:
raise DoneException
p = self.pos
- while 1:
- self.pos += 1
- if self.getc() not in alphanumerics:
- break
- name = self.s[p:self.pos]
- self.consume_whitespace()
- return name
+ try:
+ while 1:
+ self.pos += 1
+ if self.getc() not in alphanumerics:
+ break
+ except DoneException:
+ # If there's any name at all, we want to call self.set_flag().
+ # Something else while get the DoneException again.
+ if self.pos == p:
+ raise
+ else:
+ self.consume_whitespace()
+ return self.s[p:self.pos]
def get_more(self, paren_list=False):
if paren_list and self.getc() == ')':
Modified: pypy/trunk/pypy/module/__builtin__/test/test_builtin.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/test/test_builtin.py (original)
+++ pypy/trunk/pypy/module/__builtin__/test/test_builtin.py Sat Oct 24 16:35:39 2009
@@ -397,6 +397,7 @@
def test_compile(self):
co = compile('1+2', '?', 'eval')
assert eval(co) == 3
+ compile("from __future__ import with_statement", "<test>", "exec")
raises(SyntaxError, compile, '-', '?', 'eval')
raises(ValueError, compile, '"\\xt"', '?', 'eval')
raises(ValueError, compile, '1+2', '?', 'maybenot')
More information about the Pypy-commit
mailing list