STINNER Victor <vstin...@python.org> added the comment:

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;
}

----------
nosy: +lukasz.langa, vstinner
priority: normal -> release blocker

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38037>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to