mirror of https://github.com/python/cpython
bpo-38858: Fix ref leak in pycore_interp_init() (GH-17512)
bpo-38858, bpo-38997: _PySys_Create() returns a strong reference to the sys module: Py_DECREF() is needed when we are done with the module.
This commit is contained in:
parent
526606baf7
commit
080ee5a884
|
@ -705,24 +705,29 @@ static PyStatus
|
|||
pycore_interp_init(PyThreadState *tstate)
|
||||
{
|
||||
PyStatus status;
|
||||
PyObject *sysmod = NULL;
|
||||
|
||||
status = pycore_init_types(tstate);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
goto done;
|
||||
}
|
||||
|
||||
PyObject *sysmod;
|
||||
status = _PySys_Create(tstate, &sysmod);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
goto done;
|
||||
}
|
||||
|
||||
status = pycore_init_builtins(tstate);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
goto done;
|
||||
}
|
||||
|
||||
return pycore_init_import_warnings(tstate, sysmod);
|
||||
status = pycore_init_import_warnings(tstate, sysmod);
|
||||
|
||||
done:
|
||||
/* sys.modules['sys'] contains a strong reference to the module */
|
||||
Py_XDECREF(sysmod);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue