Add support for Python 3.
[binutils-gdb.git] / gdb / varobj.c
index 130f438f2d7a90f8e1d2eb66b888faa927c4d003..81b2f283540b90f0b2e7c970c843fc2f7d69209a 100644 (file)
@@ -2910,12 +2910,10 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
                       string_print.  Otherwise just return the extracted
                       string as a value.  */
 
-                   PyObject *py_str
-                     = python_string_to_target_python_string (output);
+                   char *s = python_string_to_target_string (output);
 
-                   if (py_str)
+                   if (s)
                      {
-                       char *s = PyString_AsString (py_str);
                        char *hint;
 
                        hint = gdbpy_get_display_hint (value_formatter);
@@ -2926,10 +2924,10 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
                            xfree (hint);
                          }
 
-                       len = PyString_Size (py_str);
+                       len = strlen (s);
                        thevalue = xmemdup (s, len + 1, len + 1);
                        type = builtin_type (gdbarch)->builtin_char;
-                       Py_DECREF (py_str);
+                       xfree (s);
 
                        if (!string_print)
                          {