mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Change the control flow for error handling in the function prelude to
jump to the "Kill locals" section at the end. Add #ifdef macintosh bandaid to make sure we call sigcheck() on the Mac.
This commit is contained in:
parent
43f1b8d6e4
commit
8c5df06ec7
1 changed files with 17 additions and 23 deletions
|
@ -409,6 +409,10 @@ eval_code2(co, globals, locals,
|
||||||
kwdict = newmappingobject();
|
kwdict = newmappingobject();
|
||||||
if (kwdict == NULL)
|
if (kwdict == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
i = co->co_argcount;
|
||||||
|
if (co->co_flags & CO_VARARGS)
|
||||||
|
i++;
|
||||||
|
SETLOCAL(i, kwdict);
|
||||||
}
|
}
|
||||||
if (argcount > co->co_argcount) {
|
if (argcount > co->co_argcount) {
|
||||||
if (!(co->co_flags & CO_VARARGS)) {
|
if (!(co->co_flags & CO_VARARGS)) {
|
||||||
|
@ -424,12 +428,14 @@ eval_code2(co, globals, locals,
|
||||||
}
|
}
|
||||||
if (co->co_flags & CO_VARARGS) {
|
if (co->co_flags & CO_VARARGS) {
|
||||||
u = newtupleobject(argcount - n);
|
u = newtupleobject(argcount - n);
|
||||||
|
if (u == NULL)
|
||||||
|
goto fail;
|
||||||
|
SETLOCAL(co->co_argcount, u);
|
||||||
for (i = n; i < argcount; i++) {
|
for (i = n; i < argcount; i++) {
|
||||||
x = args[i];
|
x = args[i];
|
||||||
INCREF(x);
|
INCREF(x);
|
||||||
SETTUPLEITEM(u, i-n, x);
|
SETTUPLEITEM(u, i-n, x);
|
||||||
}
|
}
|
||||||
SETLOCAL(co->co_argcount, u);
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < kwcount; i++) {
|
for (i = 0; i < kwcount; i++) {
|
||||||
object *keyword = kws[2*i];
|
object *keyword = kws[2*i];
|
||||||
|
@ -479,25 +485,11 @@ eval_code2(co, globals, locals,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (kwdict != NULL) {
|
|
||||||
i = co->co_argcount;
|
|
||||||
if (co->co_flags & CO_VARARGS)
|
|
||||||
i++;
|
|
||||||
SETLOCAL(i, kwdict);
|
|
||||||
}
|
|
||||||
if (0) {
|
|
||||||
fail:
|
|
||||||
XDECREF(kwdict);
|
|
||||||
goto fail2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (argcount > 0 || kwcount > 0) {
|
if (argcount > 0 || kwcount > 0) {
|
||||||
err_setstr(TypeError, "no arguments expected");
|
err_setstr(TypeError, "no arguments expected");
|
||||||
fail2:
|
goto fail;
|
||||||
current_frame = f->f_back;
|
|
||||||
DECREF(f);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,9 +509,7 @@ eval_code2(co, globals, locals,
|
||||||
if (call_trace(&sys_trace, &f->f_trace, f, "call",
|
if (call_trace(&sys_trace, &f->f_trace, f, "call",
|
||||||
None/*XXX how to compute arguments now?*/)) {
|
None/*XXX how to compute arguments now?*/)) {
|
||||||
/* Trace function raised an error */
|
/* Trace function raised an error */
|
||||||
current_frame = f->f_back;
|
goto fail;
|
||||||
DECREF(f);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,9 +518,7 @@ eval_code2(co, globals, locals,
|
||||||
itself and isn't called for "line" events */
|
itself and isn't called for "line" events */
|
||||||
if (call_trace(&sys_profile, (object**)0, f, "call",
|
if (call_trace(&sys_profile, (object**)0, f, "call",
|
||||||
None/*XXX*/)) {
|
None/*XXX*/)) {
|
||||||
current_frame = f->f_back;
|
goto fail;
|
||||||
DECREF(f);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,6 +555,9 @@ eval_code2(co, globals, locals,
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef macintosh
|
||||||
|
#undef HAVE_SIGNAL_H
|
||||||
|
#endif
|
||||||
#ifndef HAVE_SIGNAL_H /* Is this the right #define? */
|
#ifndef HAVE_SIGNAL_H /* Is this the right #define? */
|
||||||
/* If we have true signals, the signal handler will call
|
/* If we have true signals, the signal handler will call
|
||||||
Py_AddPendingCall() so we don't have to call sigcheck().
|
Py_AddPendingCall() so we don't have to call sigcheck().
|
||||||
|
@ -1697,6 +1688,10 @@ eval_code2(co, globals, locals,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--recursion_depth;
|
||||||
|
|
||||||
|
fail: /* Jump here from prelude on failure */
|
||||||
|
|
||||||
/* Kill all local variables */
|
/* Kill all local variables */
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1713,7 +1708,6 @@ eval_code2(co, globals, locals,
|
||||||
|
|
||||||
current_frame = f->f_back;
|
current_frame = f->f_back;
|
||||||
DECREF(f);
|
DECREF(f);
|
||||||
--recursion_depth;
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue