This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] Fix error checking and error strings in python.c
- From: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- To: archer ml <archer at sourceware dot org>
- Date: Sat, 22 Nov 2008 17:53:30 -0200
- Subject: [python] Fix error checking and error strings in python.c
Hi,
PyRun_SimpleString returns 0 on success and -1 on failure. This patch
makes python.c check it correctly, and throw a GDB exception
accordingly. Also, minor fixes to error strings.
--
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center
2008-11-22 Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (eval_python_from_control_command): Fix error
checking of function PyRun_SimpleString. Fix error string.
(python_command): Likewise.
diff --git a/gdb/python/python.c b/gdb/python/python.c
index a9b5ef4..d263b77 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -104,6 +104,7 @@ compute_python_string (struct command_line *l)
void
eval_python_from_control_command (struct command_line *cmd)
{
+ int ret;
char *script;
struct cleanup *cleanup;
PyGILState_STATE state;
@@ -115,12 +116,12 @@ eval_python_from_control_command (struct command_line *cmd)
cleanup = make_cleanup_py_restore_gil (&state);
script = compute_python_string (cmd->body_list[0]);
- PyRun_SimpleString (script);
+ ret = PyRun_SimpleString (script);
xfree (script);
- if (PyErr_Occurred ())
+ if (ret)
{
gdbpy_print_stack ();
- error (_("error while executing Python code"));
+ error (_("Error while executing Python code."));
}
do_cleanups (cleanup);
@@ -141,11 +142,10 @@ python_command (char *arg, int from_tty)
++arg;
if (arg && *arg)
{
- PyRun_SimpleString (arg);
- if (PyErr_Occurred ())
+ if (PyRun_SimpleString (arg))
{
gdbpy_print_stack ();
- error (_("error while executing Python code"));
+ error (_("Error while executing Python code."));
}
}
else
--
1.5.6.5