[pypy-commit] pypy stdlib-2.7.3: CPython issue #13268: Don't let a tuple msg be interpreted as arguments to AssertionError
amauryfa
noreply at buildbot.pypy.org
Tue Jun 12 23:22:29 CEST 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: stdlib-2.7.3
Changeset: r55633:11473d524de9
Date: 2012-06-12 22:34 +0200
http://bitbucket.org/pypy/pypy/changeset/11473d524de9/
Log: CPython issue #13268: Don't let a tuple msg be interpreted as
arguments to AssertionError
diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py
--- a/pypy/interpreter/astcompiler/codegen.py
+++ b/pypy/interpreter/astcompiler/codegen.py
@@ -376,9 +376,8 @@
self.emit_op_name(ops.LOAD_GLOBAL, self.names, "AssertionError")
if asrt.msg:
asrt.msg.walkabout(self)
- self.emit_op_arg(ops.RAISE_VARARGS, 2)
- else:
- self.emit_op_arg(ops.RAISE_VARARGS, 1)
+ self.emit_op_arg(ops.CALL_FUNCTION, 1)
+ self.emit_op_arg(ops.RAISE_VARARGS, 1)
self.use_next_block(end)
def _binop(self, op):
diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -805,6 +805,13 @@
assert s.getvalue() == "hi lovely!"
""" in {}
+ def test_assert_with_tuple_arg(self):
+ try:
+ assert False, (3,)
+ except AssertionError, e:
+ assert str(e) == "(3,)"
+
+
class TestOptimizations:
def count_instructions(self, source):
code, blocks = generate_function_code(source, self.space)
More information about the pypy-commit
mailing list