mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Make first raise argument optional
This commit is contained in:
parent
926f13a081
commit
d295f120ae
4 changed files with 26 additions and 9 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue