comparison Python/sysmodule.c @ 86715:4ef4578db38a

Issue #18408: Add a new PyFrame_FastToLocalsWithError() function to handle exceptions when merging fast locals into f_locals of a frame. PyEval_GetLocals() now raises an exception and return NULL on failure.
author Victor Stinner <victor.stinner@gmail.com>
date Tue, 29 Oct 2013 01:19:37 +0100
parents 5eb00460e6e8
children a2f42d57b91d
comparison
equal deleted inserted replaced
86714:6b86eb127030 86715:4ef4578db38a
330 330
331 static PyObject * 331 static PyObject *
332 call_trampoline(PyThreadState *tstate, PyObject* callback, 332 call_trampoline(PyThreadState *tstate, PyObject* callback,
333 PyFrameObject *frame, int what, PyObject *arg) 333 PyFrameObject *frame, int what, PyObject *arg)
334 { 334 {
335 PyObject *args = PyTuple_New(3); 335 PyObject *args;
336 PyObject *whatstr; 336 PyObject *whatstr;
337 PyObject *result; 337 PyObject *result;
338 338
339 args = PyTuple_New(3);
339 if (args == NULL) 340 if (args == NULL)
340 return NULL; 341 return NULL;
342 if (PyFrame_FastToLocalsWithError(frame) < 0)
343 return NULL;
344
341 Py_INCREF(frame); 345 Py_INCREF(frame);
342 whatstr = whatstrings[what]; 346 whatstr = whatstrings[what];
343 Py_INCREF(whatstr); 347 Py_INCREF(whatstr);
344 if (arg == NULL) 348 if (arg == NULL)
345 arg = Py_None; 349 arg = Py_None;
347 PyTuple_SET_ITEM(args, 0, (PyObject *)frame); 351 PyTuple_SET_ITEM(args, 0, (PyObject *)frame);
348 PyTuple_SET_ITEM(args, 1, whatstr); 352 PyTuple_SET_ITEM(args, 1, whatstr);
349 PyTuple_SET_ITEM(args, 2, arg); 353 PyTuple_SET_ITEM(args, 2, arg);
350 354
351 /* call the Python-level function */ 355 /* call the Python-level function */
352 PyFrame_FastToLocals(frame);
353 result = PyEval_CallObject(callback, args); 356 result = PyEval_CallObject(callback, args);
354 PyFrame_LocalsToFast(frame, 1); 357 PyFrame_LocalsToFast(frame, 1);
355 if (result == NULL) 358 if (result == NULL)
356 PyTraceBack_Here(frame); 359 PyTraceBack_Here(frame);
357 360