Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax attribute lookup in warning about old-styled middleware #2340

Closed
asvetlov opened this issue Oct 18, 2017 · 6 comments
Closed

Relax attribute lookup in warning about old-styled middleware #2340

asvetlov opened this issue Oct 18, 2017 · 6 comments
Labels

Comments

@asvetlov
Copy link
Member

For class-based middleware like

class Middleware:
    async def __call__(self, app, handler):
          ...

there is no __name__ attr.
Moreover I could imaging other situations where __name__ doesn't exists.
It breaks web server starting.

Let's change middleware.__name__ to repr(middleware).

Bugfix should be done in 2.3 branch.

@samuelcolvin
Copy link
Member

do you want me to do this?

@asvetlov
Copy link
Member Author

Could you do it asap? Otherwise I'll make a fix myself.
Because I'm blocked on switching to new aiohttp release.
Another finding: even if I decorated the method the check doesn't work:

class Middleware:
    @web.middleware
    async def __call__(self, app, handler):
          ...

_prepare_middlewares() should look on __func__ in case of methoddescriptor.

@samuelcolvin
Copy link
Member

Sounds like you know what it needs to do and need the fix. Maybe best if you fix it.

@asvetlov
Copy link
Member Author

Deal

asvetlov added a commit that referenced this issue Oct 18, 2017
* Fix #2340: Relax attribute lookup in warning about old-styled middleware

* Add missing changelog

* Fix tests on Windows
@asvetlov
Copy link
Member Author

Fixed by #2341

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants