diff options
author | Tom Tromey <tromey@adacore.com> | 2019-03-05 14:58:24 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-03-05 15:01:59 -0700 |
commit | ea38e5df7707949c20a92004f0f66efb4a9ff2a5 (patch) | |
tree | 3f1984782c941ea7d6fadcaf57d97761eb4c90c6 /gdb/python/py-utils.c | |
parent | 06b5b831a09417bac37b44599dc35d4b904700c5 (diff) | |
download | gdb-ea38e5df7707949c20a92004f0f66efb4a9ff2a5.zip gdb-ea38e5df7707949c20a92004f0f66efb4a9ff2a5.tar.gz gdb-ea38e5df7707949c20a92004f0f66efb4a9ff2a5.tar.bz2 |
Remove some Python 3 #ifs
A recent patch from Kevin Buettner taught me that the PyBytes API is
available on Python 2. This patch removes a couple of related #ifs in
the Python code.
Tested on x86-64 Fedora 29, using both Python 3.7 and Python 2.7.
gdb/ChangeLog
2019-03-05 Tom Tromey <tromey@adacore.com>
* python/py-prettyprint.c (print_string_repr): Remove #if.
* python/py-utils.c (unicode_to_encoded_string): Remove #if.
Diffstat (limited to 'gdb/python/py-utils.c')
-rw-r--r-- | gdb/python/py-utils.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index a380b34..d470000 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -66,20 +66,13 @@ python_string_to_unicode (PyObject *obj) static gdb::unique_xmalloc_ptr<char> unicode_to_encoded_string (PyObject *unicode_str, const char *charset) { - gdb::unique_xmalloc_ptr<char> result; - /* Translate string to named charset. */ gdbpy_ref<> string (PyUnicode_AsEncodedString (unicode_str, charset, NULL)); if (string == NULL) return NULL; -#ifdef IS_PY3K - result.reset (xstrdup (PyBytes_AsString (string.get ()))); -#else - result.reset (xstrdup (PyString_AsString (string.get ()))); -#endif - - return result; + return gdb::unique_xmalloc_ptr<char> + (xstrdup (PyBytes_AsString (string.get ()))); } /* Returns a PyObject with the contents of the given unicode string |