]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/python/py-type.c
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / python / py-type.c
index e8af6f60e1e5a35db388355b337a12f2136cad44..b19cad098a46410262080cd2b1aaa8f8f1729ea6 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to types.
 
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
+   Copyright (C) 2008-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -26,7 +26,6 @@
 #include "demangle.h"
 #include "objfiles.h"
 #include "language.h"
-#include "gdbsupport/vec.h"
 #include "typeprint.h"
 
 typedef struct pyty_type_object
@@ -759,7 +758,7 @@ typy_lookup_typename (const char *type_name, const struct block *block)
       else if (startswith (type_name, "enum "))
        type = lookup_enum (type_name + 5, NULL);
       else
-       type = lookup_typename (python_language, python_gdbarch,
+       type = lookup_typename (python_language,
                                type_name, block, 0);
     }
   catch (const gdb_exception &except)
@@ -1326,6 +1325,7 @@ typy_iterator_dealloc (PyObject *obj)
   typy_iterator_object *iter_obj = (typy_iterator_object *) obj;
 
   Py_DECREF (iter_obj->source);
+  Py_TYPE (obj)->tp_free (obj);
 }
 
 /* Create a new Type referring to TYPE.  */
@@ -1334,6 +1334,17 @@ type_to_type_object (struct type *type)
 {
   type_object *type_obj;
 
+  try
+    {
+      /* Try not to let stub types leak out to Python.  */
+      if (TYPE_STUB (type))
+       type = check_typedef (type);
+    }
+  catch (...)
+    {
+      /* Just ignore failures in check_typedef.  */
+    }
+
   type_obj = PyObject_New (type_object, &type_object_type);
   if (type_obj)
     set_type (type_obj, type);