summaryrefslogtreecommitdiff
path: root/gdb/python/py-value.c
diff options
context:
space:
mode:
authorpmuldoon <pmuldoon>2013-10-03 14:43:30 +0000
committerpmuldoon <pmuldoon>2013-10-03 14:43:30 +0000
commita05b62e2ce3b4e82a7f2ec22df7ad907949c478d (patch)
tree0235985c7a5256ccb2bc9fe590cf08d60671ccb6 /gdb/python/py-value.c
parent686117608240f09fc72ba40ccac1db804e66243a (diff)
downloadgdb-a05b62e2ce3b4e82a7f2ec22df7ad907949c478d.tar.gz
2013-10-03 Phil Muldoon <pmuldoon@redhat.com>
* python/py-value.c (convert_value_from_python): Move PyInt_Check conversion logic to occur after PyLong_Check. Comment on order change significance. * python/py-arch.c (archpy_disassemble): Comment on order of conversion for integers and longs.
Diffstat (limited to 'gdb/python/py-value.c')
-rw-r--r--gdb/python/py-value.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 0d87219ae84..07feaf817c5 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1265,13 +1265,13 @@ convert_value_from_python (PyObject *obj)
if (cmp >= 0)
value = value_from_longest (builtin_type_pybool, cmp);
}
- else if (PyInt_Check (obj))
- {
- long l = PyInt_AsLong (obj);
-
- if (! PyErr_Occurred ())
- value = value_from_longest (builtin_type_pyint, l);
- }
+ /* Make a long logic check first. In Python 3.x, internally,
+ all integers are represented as longs. In Python 2.x, there
+ is still a differentiation internally between a PyInt and a
+ PyLong. Explicitly do this long check conversion first. In
+ GDB, for Python 3.x, we #ifdef PyInt = PyLong. This check has
+ to be done first to ensure we do not lose information in the
+ conversion process. */
else if (PyLong_Check (obj))
{
LONGEST l = PyLong_AsLongLong (obj);
@@ -1306,6 +1306,13 @@ convert_value_from_python (PyObject *obj)
else
value = value_from_longest (builtin_type_pylong, l);
}
+ else if (PyInt_Check (obj))
+ {
+ long l = PyInt_AsLong (obj);
+
+ if (! PyErr_Occurred ())
+ value = value_from_longest (builtin_type_pyint, l);
+ }
else if (PyFloat_Check (obj))
{
double d = PyFloat_AsDouble (obj);