[3.13] gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812) (#120843)

gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812)
(cherry picked from commit aed31beca9)

Co-authored-by: Peter <zintensitydev@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
Miss Islington (bot) 2024-06-22 13:14:46 +02:00 committed by GitHub
parent 4fabbf9773
commit a860b1d60b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -0,0 +1 @@
Fix possible memory leak in :meth:`contextvars.Context.run`.

View File

@ -661,6 +661,7 @@ context_run(PyContext *self, PyObject *const *args,
ts, args[0], args + 1, nargs - 1, kwnames);
if (_PyContext_Exit(ts, (PyObject *)self)) {
Py_XDECREF(call_result);
return NULL;
}