public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-tromey-python: PyObject_IsTrue houskeeping rework.
@ 2009-01-27 9:57 pmuldoon
0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2009-01-27 9:57 UTC (permalink / raw)
To: archer-commits
The branch, archer-tromey-python has been updated
via d0ca6a3d7a10b83e2c16e6e79ecbd86f1f9c6aef (commit)
from 978d5a7ac23e12941f7ab012701484f968877ba3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit d0ca6a3d7a10b83e2c16e6e79ecbd86f1f9c6aef
Author: Phil Muldoon <pmuldoon@redhat.com>
Date: Tue Jan 27 09:56:16 2009 +0000
PyObject_IsTrue houskeeping rework.
2009-01-26 Phil Muldoon <pmuldoon@redhat.com>
* python/python-breakpoint.c (bppy_set_enabled): Use
PyObject_IsTrue and account for comparison failure.
(bppy_set_silent): Likewise.
* python/python-cmd.c (cmdpy_init): Likewise.
* python/python-param.c (set_parameter_value): Likewise.
* python/python-value.c (convert_value_from_python): Likewise.
* python/python.c (execute_gdb_command): Likewise.
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 10 ++++++++
gdb/python/python-breakpoint.c | 18 ++++++++++----
gdb/python/python-cmd.c | 48 ++++++++++++++++++++++-----------------
gdb/python/python-param.c | 28 ++++++++++++++++------
gdb/python/python-value.c | 9 +++++-
gdb/python/python.c | 8 +++++-
6 files changed, 84 insertions(+), 37 deletions(-)
First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a2e5838..0742753 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2009-01-26 Phil Muldoon <pmuldoon@redhat.com>
+
+ * python/python-breakpoint.c (bppy_set_enabled): Use
+ PyObject_IsTrue and account for comparison failure.
+ (bppy_set_silent): Likewise.
+ * python/python-cmd.c (cmdpy_init): Likewise.
+ * python/python-param.c (set_parameter_value): Likewise.
+ * python/python-value.c (convert_value_from_python): Likewise.
+ * python/python.c (execute_gdb_command): Likewise.
+
2009-01-14 Tom Tromey <tromey@redhat.com>
* darwin-nat-info.c (info_mach_region_command): Use
diff --git a/gdb/python/python-breakpoint.c b/gdb/python/python-breakpoint.c
index 4c79093..5e87af6 100644
--- a/gdb/python/python-breakpoint.c
+++ b/gdb/python/python-breakpoint.c
@@ -1,6 +1,6 @@
/* Python interface to breakpoints
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009 Free Software Foundation, Inc.
This file is part of GDB.
@@ -129,6 +129,7 @@ static int
bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
{
breakpoint_object *self_bp = (breakpoint_object *) self;
+ int cmp;
BPPY_SET_REQUIRE_VALID (self_bp);
@@ -144,11 +145,13 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
return -1;
}
- if (newvalue == Py_True)
+ cmp = PyObject_IsTrue (newvalue);
+ if (cmp < 0)
+ return -1;
+ else if (cmp == 1)
enable_breakpoint (self_bp->bp);
- else
+ else
disable_breakpoint (self_bp->bp);
-
return 0;
}
@@ -157,6 +160,7 @@ static int
bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure)
{
breakpoint_object *self_bp = (breakpoint_object *) self;
+ int cmp;
BPPY_SET_REQUIRE_VALID (self_bp);
@@ -172,7 +176,11 @@ bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure)
return -1;
}
- self_bp->bp->silent = (newvalue == Py_True);
+ cmp = PyObject_IsTrue (newvalue);
+ if (cmp < 0)
+ return -1;
+ else
+ self_bp->bp->silent = cmp;
return 0;
}
diff --git a/gdb/python/python-cmd.c b/gdb/python/python-cmd.c
index 014274b..61d5e5d 100644
--- a/gdb/python/python-cmd.c
+++ b/gdb/python/python-cmd.c
@@ -1,6 +1,6 @@
/* gdb commands implemented in Python
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009 Free Software Foundation, Inc.
This file is part of GDB.
@@ -370,6 +370,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kwds)
struct cmd_list_element **cmd_list;
char *cmd_name, *pfx_name;
PyObject *is_prefix = NULL;
+ int cmp;
if (obj->command)
{
@@ -406,30 +407,35 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kwds)
return -1;
pfx_name = NULL;
- if (is_prefix == Py_True)
+ if (is_prefix != NULL)
{
- int i, out;
-
- /* Make a normalized form of the command name. */
- pfx_name = xmalloc (strlen (name) + 2);
-
- i = 0;
- out = 0;
- while (name[i])
+ cmp = PyObject_IsTrue (is_prefix);
+ if (cmp == 1)
{
- /* Skip whitespace. */
- while (name[i] == ' ' || name[i] == '\t')
- ++i;
- /* Copy non-whitespace characters. */
- while (name[i] && name[i] != ' ' && name[i] != '\t')
- pfx_name[out++] = name[i++];
- /* Add a single space after each word -- including the final
- word. */
- pfx_name[out++] = ' ';
+ int i, out;
+
+ /* Make a normalized form of the command name. */
+ pfx_name = xmalloc (strlen (name) + 2);
+
+ i = 0;
+ out = 0;
+ while (name[i])
+ {
+ /* Skip whitespace. */
+ while (name[i] == ' ' || name[i] == '\t')
+ ++i;
+ /* Copy non-whitespace characters. */
+ while (name[i] && name[i] != ' ' && name[i] != '\t')
+ pfx_name[out++] = name[i++];
+ /* Add a single space after each word -- including the final
+ word. */
+ pfx_name[out++] = ' ';
+ }
+ pfx_name[out] = '\0';
}
- pfx_name[out] = '\0';
+ else if (cmp < 0)
+ return -1;
}
-
if (PyObject_HasAttr (self, gdbpy_doc_cst))
{
PyObject *ds_obj = PyObject_GetAttr (self, gdbpy_doc_cst);
diff --git a/gdb/python/python-param.c b/gdb/python/python-param.c
index dc1aec3..1f591a8 100644
--- a/gdb/python/python-param.c
+++ b/gdb/python/python-param.c
@@ -1,6 +1,6 @@
/* gdb parameters implemented in Python
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009 Free Software Foundation, Inc.
This file is part of GDB.
@@ -114,6 +114,8 @@ get_attr (PyObject *obj, PyObject *attr_name)
static int
set_parameter_value (parmpy_object *self, PyObject *value)
{
+ int cmp;
+
switch (self->type)
{
case var_string:
@@ -172,7 +174,10 @@ set_parameter_value (parmpy_object *self, PyObject *value)
PyErr_SetString (PyExc_RuntimeError, "boolean required");
return -1;
}
- self->value.intval = value == Py_True;
+ cmp = PyObject_IsTrue (value);
+ if (cmp < 0)
+ return -1;
+ self->value.intval = cmp;
break;
case var_auto_boolean:
@@ -183,13 +188,20 @@ set_parameter_value (parmpy_object *self, PyObject *value)
return -1;
}
- if (value == Py_True)
- self->value.autoboolval = AUTO_BOOLEAN_TRUE;
- else if (value == Py_False)
- self->value.autoboolval = AUTO_BOOLEAN_FALSE;
- else
+ if (value == Py_None)
self->value.autoboolval = AUTO_BOOLEAN_AUTO;
- break;
+ else
+ {
+ cmp = PyObject_IsTrue (value);
+ if (cmp < 0 )
+ return -1;
+ if (cmp == 1)
+ self->value.autoboolval = AUTO_BOOLEAN_TRUE;
+ else
+ self->value.autoboolval = AUTO_BOOLEAN_FALSE;
+
+ break;
+ }
case var_integer:
case var_zinteger:
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index c329604..53dcb74 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -779,12 +779,17 @@ convert_value_from_python (PyObject *obj)
struct value *value = NULL; /* -Wall */
PyObject *target_str, *unicode_str;
struct cleanup *old;
+ int cmp;
if (! obj)
error (_("Internal error while converting Python value."));
- if (PyBool_Check (obj))
- value = value_from_longest (builtin_type_pybool, obj == Py_True);
+ if (PyBool_Check (obj))
+ {
+ cmp = PyObject_IsTrue (obj);
+ if (cmp >= 0)
+ value = value_from_longest (builtin_type_pybool, cmp);
+ }
else if (PyInt_Check (obj))
value = value_from_longest (builtin_type_pyint, PyInt_AsLong (obj));
else if (PyLong_Check (obj))
diff --git a/gdb/python/python.c b/gdb/python/python.c
index bdb5319..8fdf1fb 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -260,6 +260,7 @@ execute_gdb_command (PyObject *self, PyObject *args)
char *arg, *newarg;
PyObject *from_tty_obj = NULL;
int from_tty;
+ int cmp;
volatile struct gdb_exception except;
if (! PyArg_ParseTuple (args, "s|O!", &arg, &PyBool_Type, &from_tty_obj))
@@ -267,7 +268,12 @@ execute_gdb_command (PyObject *self, PyObject *args)
from_tty = 0;
if (from_tty_obj)
- from_tty = from_tty_obj == Py_True;
+ {
+ cmp = PyObject_IsTrue (from_tty_obj);
+ if (cmp < 0)
+ return NULL;
+ from_tty = cmp;
+ }
TRY_CATCH (except, RETURN_MASK_ALL)
{
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-01-27 9:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-27 9:57 [SCM] archer-tromey-python: PyObject_IsTrue houskeeping rework pmuldoon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).