Author vstinner
Recipients berker.peksag, lukasz.langa, malin, nanjekyejoannah, vstinner
Date 2019-09-06.13:44:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567777479.99.0.123525724661.issue38037@roundup.psfhosted.org>
In-reply-to
Content
This issue is a Python 3.8 regression.

Joannah: Would you mind to have a look?

    x = DefaultHandler = PyLong_FromVoidPtr((void *)SIG_DFL);
    if (PyModule_AddObject(m, "SIG_DFL", x))
        goto finally;

This change is not easy to read.

DefaultHandler must be a strong reference: finisignal() calls Py_CLEAR(DefaultHandler);

Previously, the code uses PyDict_SetItemString(d, "SIG_DFL", x): PyDict_SetItemString increases the reference counter, whereas PyModule_AddObject leaves the reference counter unchanged (yeah, it's a strange/bad C API).

I guess than an INCREF() is needed somewhere.

Compare it to:

int
PyModule_AddIntConstant(PyObject *m, const char *name, long value)
{
    PyObject *o = PyLong_FromLong(value);
    if (!o)
        return -1;
    if (PyModule_AddObject(m, name, o) == 0)
        return 0;
    Py_DECREF(o);
    return -1;
}
History
Date User Action Args
2019-09-06 13:44:40vstinnersetrecipients: + vstinner, lukasz.langa, berker.peksag, malin, nanjekyejoannah
2019-09-06 13:44:39vstinnersetmessageid: <1567777479.99.0.123525724661.issue38037@roundup.psfhosted.org>
2019-09-06 13:44:39vstinnerlinkissue38037 messages
2019-09-06 13:44:39vstinnercreate