summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/NEWS5
-rw-r--r--gdb/python/py-progspace.c16
-rw-r--r--gdb/testsuite/gdb.python/py-progspace.exp6
3 files changed, 12 insertions, 15 deletions
diff --git a/gdb/NEWS b/gdb/NEWS
index 76bc131e9c9..72549733dce 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -95,6 +95,11 @@ show remote thread-options-packet
attribute contains the string that appears in the 'Target Id'
column of the 'info threads' command output.
+ ** It is no longer possible to create new gdb.Progspace object using
+ 'gdb.Progspace()', this will result in a TypeError. Progspace
+ objects can still be obtained through calling other API
+ functions, for example 'gdb.current_progspace()'.
+
* Debugger Adapter Protocol changes
** GDB now emits the "process" event.
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index 0797ef1fa6b..bfc6ff50f01 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -210,20 +210,6 @@ pspy_initialize (pspace_object *self)
return 1;
}
-static PyObject *
-pspy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
-{
- gdbpy_ref<pspace_object> self ((pspace_object *) type->tp_alloc (type, 0));
-
- if (self != NULL)
- {
- if (!pspy_initialize (self.get ()))
- return NULL;
- }
-
- return (PyObject *) self.release ();
-}
-
PyObject *
pspy_get_printers (PyObject *o, void *ignore)
{
@@ -859,5 +845,5 @@ PyTypeObject pspace_object_type =
offsetof (pspace_object, dict), /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- pspy_new, /* tp_new */
+ 0, /* tp_new */
};
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index befd6433e47..5f6a9577f82 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -53,6 +53,12 @@ gdb_py_test_silent_cmd "python progspace.random_attribute = 42" \
gdb_test "python print (progspace.random_attribute)" "42" \
"Verify set of random attribute in progspace"
+# Check that we can't create new (invalid) gdb.Progspace objects.
+gdb_test "python gdb.Progspace()" \
+ [multi_line "TypeError: cannot create 'gdb.Progspace' instances" \
+ "Error while executing Python code\\."] \
+ "check for error when calling gdb.Progspace() directly"
+
if {![runto_main]} {
return
}