diff options
Diffstat (limited to 'gdb/python/py-utils.c')
-rw-r--r-- | gdb/python/py-utils.c | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 838853c..e7b147c 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -45,14 +45,10 @@ python_string_to_unicode (PyObject *obj) unicode_str = obj; Py_INCREF (obj); } -#ifndef IS_PY3K - else if (PyString_Check (obj)) - unicode_str = PyUnicode_FromEncodedObject (obj, host_charset (), NULL); -#endif else { PyErr_SetString (PyExc_TypeError, - _("Expected a string or unicode object.")); + _("Expected a string object.")); unicode_str = NULL; } @@ -166,11 +162,7 @@ host_string_to_python_string (const char *str) int gdbpy_is_string (PyObject *obj) { -#ifdef IS_PY3K return PyUnicode_Check (obj); -#else - return PyString_Check (obj) || PyUnicode_Check (obj); -#endif } /* Return the string representation of OBJ, i.e., str (obj). @@ -182,17 +174,7 @@ gdbpy_obj_to_string (PyObject *obj) gdbpy_ref<> str_obj (PyObject_Str (obj)); if (str_obj != NULL) - { - gdb::unique_xmalloc_ptr<char> msg; - -#ifdef IS_PY3K - msg = python_string_to_host_string (str_obj.get ()); -#else - msg.reset (xstrdup (PyString_AsString (str_obj.get ()))); -#endif - - return msg; - } + return python_string_to_host_string (str_obj.get ()); return NULL; } @@ -296,20 +278,9 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr) gdbpy_ref<> gdb_py_object_from_longest (LONGEST l) { -#ifdef IS_PY3K if (sizeof (l) > sizeof (long)) return gdbpy_ref<> (PyLong_FromLongLong (l)); return gdbpy_ref<> (PyLong_FromLong (l)); -#else -#ifdef HAVE_LONG_LONG /* Defined by Python. */ - /* If we have 'long long', and the value overflows a 'long', use a - Python Long; otherwise use a Python Int. */ - if (sizeof (l) > sizeof (long) - && (l > PyInt_GetMax () || l < (- (LONGEST) PyInt_GetMax ()) - 1)) - return gdbpy_ref<> (PyLong_FromLongLong (l)); -#endif - return gdbpy_ref<> (PyInt_FromLong (l)); -#endif } /* Convert a ULONGEST to the appropriate Python object -- either an @@ -318,23 +289,9 @@ gdb_py_object_from_longest (LONGEST l) gdbpy_ref<> gdb_py_object_from_ulongest (ULONGEST l) { -#ifdef IS_PY3K if (sizeof (l) > sizeof (unsigned long)) return gdbpy_ref<> (PyLong_FromUnsignedLongLong (l)); return gdbpy_ref<> (PyLong_FromUnsignedLong (l)); -#else -#ifdef HAVE_LONG_LONG /* Defined by Python. */ - /* If we have 'long long', and the value overflows a 'long', use a - Python Long; otherwise use a Python Int. */ - if (sizeof (l) > sizeof (unsigned long) && l > PyInt_GetMax ()) - return gdbpy_ref<> (PyLong_FromUnsignedLongLong (l)); -#endif - - if (l > PyInt_GetMax ()) - return gdbpy_ref<> (PyLong_FromUnsignedLong (l)); - - return gdbpy_ref<> (PyInt_FromLong (l)); -#endif } /* Like PyInt_AsLong, but returns 0 on failure, 1 on success, and puts |