Python: allocate py_req in the http_request_free hook if needed.

Makes it possible to mix on_free with other runtimes.
This commit is contained in:
Joris Vink 2021-12-15 12:19:04 +01:00
parent e545657023
commit a3800fa57e
1 changed files with 4 additions and 2 deletions

View File

@ -1331,8 +1331,10 @@ python_runtime_http_request_free(void *addr, struct http_request *req)
{
PyObject *ret;
if (req->py_req == NULL)
fatal("%s: py_req is NULL", __func__);
if (req->py_req == NULL) {
if ((req->py_req = pyhttp_request_alloc(req)) == NULL)
fatal("%s: pyreq alloc failed", __func__);
}
PyErr_Clear();
ret = PyObject_CallFunctionObjArgs(addr, req->py_req, NULL);