[pypy-svn] r79933 - in pypy/trunk/pypy: interpreter/pyparser/test interpreter/test module/exceptions
arigo at codespeak.net
arigo at codespeak.net
Thu Dec 9 15:08:53 CET 2010
Author: arigo
Date: Thu Dec 9 15:08:51 2010
New Revision: 79933
Modified:
pypy/trunk/pypy/interpreter/pyparser/test/test_pyparse.py
pypy/trunk/pypy/interpreter/test/test_compiler.py
pypy/trunk/pypy/module/exceptions/interp_exceptions.py
Log:
Fix for the stdlib's test_traceback: make sure that SyntaxError().args[1] is a 4-tuple,
as in CPython, and not a 5-tuple. Apparently traceback.format_exception_only() is
sensible to that.
Modified: pypy/trunk/pypy/interpreter/pyparser/test/test_pyparse.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyparser/test/test_pyparse.py (original)
+++ pypy/trunk/pypy/interpreter/pyparser/test/test_pyparse.py Thu Dec 9 15:08:51 2010
@@ -100,6 +100,7 @@
input = "def f():\n pass\n next_stmt"
exc = py.test.raises(IndentationError, parse, input).value
assert exc.msg == "unindent does not match any outer indentation level"
+ assert exc.lineno == 3
def test_mac_newline(self):
self.parse("this_is\ra_mac\rfile")
Modified: pypy/trunk/pypy/interpreter/test/test_compiler.py
==============================================================================
--- pypy/trunk/pypy/interpreter/test/test_compiler.py (original)
+++ pypy/trunk/pypy/interpreter/test/test_compiler.py Thu Dec 9 15:08:51 2010
@@ -68,6 +68,17 @@
space.raises_w(space.w_SyntaxError, self.compiler.compile_command,
'if 1:\n x\n y\n', '?', 'exec', 0)
+ def test_syntaxerror_attrs(self):
+ w_args = self.space.appexec([], r"""():
+ try:
+ exec 'if 1:\n x\n y\n'
+ except SyntaxError, e:
+ return e.args
+ """)
+ assert self.space.unwrap(w_args) == (
+ 'unindent does not match any outer indentation level',
+ (None, 3, 0, ' y\n'))
+
def test_getcodeflags(self):
code = self.compiler.compile('from __future__ import division\n',
'<hello>', 'exec', 0)
Modified: pypy/trunk/pypy/module/exceptions/interp_exceptions.py
==============================================================================
--- pypy/trunk/pypy/module/exceptions/interp_exceptions.py (original)
+++ pypy/trunk/pypy/module/exceptions/interp_exceptions.py Thu Dec 9 15:08:51 2010
@@ -465,7 +465,11 @@
if len(values_w) > 1: self.w_lineno = values_w[1]
if len(values_w) > 2: self.w_offset = values_w[2]
if len(values_w) > 3: self.w_text = values_w[3]
- if len(values_w) > 4: self.w_lastlineno = values_w[4]
+ if len(values_w) > 4:
+ self.w_lastlineno = values_w[4] # PyPy extension
+ # kill the extra items from args_w to prevent undesired effects
+ args_w = args_w[:]
+ args_w[1] = space.newtuple(values_w[:4])
W_BaseException.descr_init(self, space, args_w)
descr_init.unwrap_spec = ['self', ObjSpace, 'args_w']
More information about the Pypy-commit
mailing list