[issue43916] Check that new heap types cannot be created uninitialised

Christian Heimes report at bugs.python.org
Mon Apr 26 09:47:31 EDT 2021


Christian Heimes <lists at cheimes.de> added the comment:

I have had this workaround in _hashopenssl.c for a while. Can I get rid of the function with "{Py_tp_new, NULL}" or is there a more generic way to accomplish the same goal?

/* {Py_tp_new, NULL} doesn't block __new__ */
static PyObject *
_disabled_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
    PyErr_Format(PyExc_TypeError,
        "cannot create '%.100s' instances", _PyType_Name(type));
    return NULL;
}

----------
nosy: +christian.heimes

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43916>
_______________________________________


More information about the Python-bugs-list mailing list