diff --git a/CHANGES/4174.bugfix b/CHANGES/4174.bugfix new file mode 100644 index 00000000000..82c37e4edbc --- /dev/null +++ b/CHANGES/4174.bugfix @@ -0,0 +1 @@ +Preserve handler function attributes for the case of subapps diff --git a/aiohttp/web_app.py b/aiohttp/web_app.py index 90915d2b9c9..8ce59b1748b 100644 --- a/aiohttp/web_app.py +++ b/aiohttp/web_app.py @@ -1,7 +1,7 @@ import asyncio import logging import warnings -from functools import partial +from functools import partial, update_wrapper from typing import ( # noqa TYPE_CHECKING, Any, @@ -325,7 +325,9 @@ async def _handle(self, request: Request) -> StreamResponse: for app in match_info.apps[::-1]: assert app.pre_frozen, "middleware handlers are not ready" for m in app._middlewares_handlers: # noqa - handler = partial(m, handler=handler) + handler = update_wrapper( + partial(m, handler=handler), handler + ) resp = await handler(request)