summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-04-09 21:39:57 (GMT)
committerGuido van Rossum <guido@python.org>1998-04-09 21:39:57 (GMT)
commitd295f120ae6bd624eaac9032b70fad0aec110597 (patch)
treeb35a80e21cc3bceff0cc766d15582cf30c02225f /Python/ceval.c
parent926f13a0819eb3d40a0d0fd38ff25ef0c7d489b3 (diff)
downloadcpython-d295f120ae6bd624eaac9032b70fad0aec110597.zip
cpython-d295f120ae6bd624eaac9032b70fad0aec110597.tar.gz
cpython-d295f120ae6bd624eaac9032b70fad0aec110597.tar.bz2
Make first raise argument optional
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index b29b5f9..28360f4 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1090,6 +1090,7 @@ eval_code2(co, globals, locals,
/* Fallthrough */
case 1:
w = POP(); /* exc */
+ case 0: /* Fallthrough */
why = do_raise(w, v, u);
break;
default:
@@ -1967,6 +1968,17 @@ static enum why_code
do_raise(type, value, tb)
PyObject *type, *value, *tb;
{
+ if (type == NULL) {
+ /* Reraise */
+ PyThreadState *tstate = PyThreadState_Get();
+ type = tstate->exc_type == NULL ? Py_None : tstate->exc_type;
+ value = tstate->exc_value;
+ tb = tstate->exc_traceback;
+ Py_XINCREF(type);
+ Py_XINCREF(value);
+ Py_XINCREF(tb);
+ }
+
/* We support the following forms of raise:
raise <class>, <classinstance>
raise <class>, <argument tuple>