Author: Ronan Lamy <[email protected]>
Branch: less-stringly-ops
Changeset: r66772:8d2a95a27c5e
Date: 2013-09-01 14:19 +0100
http://bitbucket.org/pypy/pypy/changeset/8d2a95a27c5e/
Log: Fix exception raising
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -649,14 +649,18 @@
raise const(TypeError(
"raise: no active exception to re-raise"))
- w_value = space.w_None
if nbargs >= 3:
self.popvalue()
if nbargs >= 2:
w_value = self.popvalue()
- if 1:
w_type = self.popvalue()
- operror = space.exc_from_raise(w_type, w_value)
+ operror = space.exc_from_raise(w_type, w_value)
+ else:
+ w_type = self.popvalue()
+ if isinstance(w_type, FSException):
+ operror = w_type
+ else:
+ operror = space.exc_from_raise(w_type, space.w_None)
raise operror
def IMPORT_NAME(self, nameindex):
diff --git a/rpython/flowspace/test/test_objspace.py
b/rpython/flowspace/test/test_objspace.py
--- a/rpython/flowspace/test/test_objspace.py
+++ b/rpython/flowspace/test/test_objspace.py
@@ -387,6 +387,16 @@
assert x.startblock.exits[0].args == [ops[1].result, ops[0].result]
assert x.startblock.exits[0].target is x.exceptblock
+ def test_simple_raise(self):
+ def f():
+ raise ValueError('ouch')
+ x = self.codetest(f)
+ simplify_graph(x)
+ self.show(x)
+ ops = x.startblock.operations
+ assert ops[0].opname == 'simple_call'
+ assert ops[0].args == [Constant(ValueError), Constant('ouch')]
+
#__________________________________________________________
def raise2(msg):
raise IndexError, msg
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit