diff options
-rw-r--r-- | docs/changes.xml | 7 | ||||
-rw-r--r-- | src/python/nxt_python_asgi.c | 18 |
2 files changed, 19 insertions, 6 deletions
diff --git a/docs/changes.xml b/docs/changes.xml index 64a35da8..a6b1178d 100644 --- a/docs/changes.xml +++ b/docs/changes.xml @@ -43,6 +43,13 @@ some Spring Boot applications failed to start, notably with Grails. </para> </change> +<change type="bugfix"> +<para> +incorrect Python protocol auto detection (ASGI or WSGI) for native callable +object, notably with Falcon. +</para> +</change> + </changes> diff --git a/src/python/nxt_python_asgi.c b/src/python/nxt_python_asgi.c index 354e3a81..2d3efc7d 100644 --- a/src/python/nxt_python_asgi.c +++ b/src/python/nxt_python_asgi.c @@ -117,15 +117,20 @@ nxt_python_asgi_get_func(PyObject *obj) if (PyMethod_Check(call)) { obj = PyMethod_GET_FUNCTION(call); - Py_INCREF(obj); - Py_DECREF(call); + if (PyFunction_Check(obj)) { + Py_INCREF(obj); - return obj; + } else { + obj = NULL; + } + + } else { + obj = NULL; } Py_DECREF(call); - return NULL; + return obj; } @@ -161,8 +166,9 @@ nxt_python_asgi_init(nxt_unit_init_t *init, nxt_python_proto_t *proto) for (i = 0; i < nxt_py_targets->count; i++) { func = nxt_python_asgi_get_func(nxt_py_targets->target[i].application); if (nxt_slow_path(func == NULL)) { - nxt_unit_alert(NULL, "Python cannot find function for callable"); - return NXT_UNIT_ERROR; + nxt_unit_debug(NULL, "asgi: cannot find function for callable, " + "unable to check for legacy mode (#%d)", i); + continue; } code = (PyCodeObject *) PyFunction_GET_CODE(func); |