Re: [PATCH 1/2] python: disallow python code to instanciate certain types

Tom Tromey
2013-10-10T19:08:27Z

>> -static PyObject *
>> -objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
[...]

Phil> In removing this function, you are removing the instantiation of
Phil> self-> printers (Which is needed for pretty-printers),
Phil> self-> frame-filters (for frame filters) and self->type_printers (for
Phil> type printers). If this is the case, and I have not missed an
Phil> equivalent instantiation somewhere else, you will have an
Phil> uninitialized PyObject for each of the above and likely will result in
Phil> a crash?

Internal instantiations don't go through tp_new. instead they use
PyObject_New.

In the case of objfile these fields are initialized in
objfile_to_objfile_object.

>> -static PyObject *
>> -pspy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)

Phil> Ditto, same with object files above.

This is handled in pspace_to_pspace_object.

Tom