forked from Imagelibrary/binutils-gdb
2011-10-27 Phil Muldoon <pmuldoon@redhat.com>
PR python/13331 * python/py-function.c (fnpy_call): Check 'args' is not NULL. (convert_values_to_python): Return on Python tuple allocation failure. Return NULL on value conversion error.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2011-10-27 Phil Muldoon <pmuldoon@redhat.com>
|
||||||
|
|
||||||
|
PR python/13331
|
||||||
|
|
||||||
|
* python/py-function.c (fnpy_call): Check 'args' is not NULL.
|
||||||
|
(convert_values_to_python): Return on Python tuple allocation
|
||||||
|
failure. Return NULL on value conversion error.
|
||||||
|
|
||||||
2011-10-27 Phil Muldoon <pmuldoon@redhat.com>
|
2011-10-27 Phil Muldoon <pmuldoon@redhat.com>
|
||||||
|
|
||||||
* python/py-breakpoint.c (bppy_set_enabled): Use TRY_CATCH.
|
* python/py-breakpoint.c (bppy_set_enabled): Use TRY_CATCH.
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ convert_values_to_python (int argc, struct value **argv)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyObject *result = PyTuple_New (argc);
|
PyObject *result = PyTuple_New (argc);
|
||||||
|
|
||||||
|
if (! result)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < argc; ++i)
|
for (i = 0; i < argc; ++i)
|
||||||
{
|
{
|
||||||
@@ -45,7 +48,7 @@ convert_values_to_python (int argc, struct value **argv)
|
|||||||
if (! elt)
|
if (! elt)
|
||||||
{
|
{
|
||||||
Py_DECREF (result);
|
Py_DECREF (result);
|
||||||
error (_("Could not convert value to Python object."));
|
return NULL;
|
||||||
}
|
}
|
||||||
PyTuple_SetItem (result, i, elt);
|
PyTuple_SetItem (result, i, elt);
|
||||||
}
|
}
|
||||||
@@ -59,23 +62,34 @@ fnpy_call (struct gdbarch *gdbarch, const struct language_defn *language,
|
|||||||
void *cookie, int argc, struct value **argv)
|
void *cookie, int argc, struct value **argv)
|
||||||
{
|
{
|
||||||
struct value *value = NULL;
|
struct value *value = NULL;
|
||||||
PyObject *result, *callable, *args;
|
/* 'result' must be set to NULL, this initially indicates whether
|
||||||
|
the function was called, or not. */
|
||||||
|
PyObject *result = NULL;
|
||||||
|
PyObject *callable, *args;
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
|
|
||||||
cleanup = ensure_python_env (gdbarch, language);
|
cleanup = ensure_python_env (gdbarch, language);
|
||||||
|
|
||||||
args = convert_values_to_python (argc, argv);
|
args = convert_values_to_python (argc, argv);
|
||||||
|
/* convert_values_to_python can return NULL on error. If we
|
||||||
|
encounter this, do not call the function, but allow the Python ->
|
||||||
|
error code conversion below to deal with the Python exception.
|
||||||
|
Note, that this is different if the function simply does not
|
||||||
|
have arguments. */
|
||||||
|
|
||||||
callable = PyObject_GetAttrString ((PyObject *) cookie, "invoke");
|
if (args)
|
||||||
if (! callable)
|
|
||||||
{
|
{
|
||||||
Py_DECREF (args);
|
callable = PyObject_GetAttrString ((PyObject *) cookie, "invoke");
|
||||||
error (_("No method named 'invoke' in object."));
|
if (! callable)
|
||||||
}
|
{
|
||||||
|
Py_DECREF (args);
|
||||||
|
error (_("No method named 'invoke' in object."));
|
||||||
|
}
|
||||||
|
|
||||||
result = PyObject_Call (callable, args, NULL);
|
result = PyObject_Call (callable, args, NULL);
|
||||||
Py_DECREF (callable);
|
Py_DECREF (callable);
|
||||||
Py_DECREF (args);
|
Py_DECREF (args);
|
||||||
|
}
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user