-
-
Notifications
You must be signed in to change notification settings - Fork 903
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
Fix routing.get_name()
not to assume all routines have __name__
#2648
Conversation
Can we link the CPython PR here? I don't understand why change this behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh well... Seems okay anyway. If it has a __name__
, use it, otherwise use __class__.__name__
.
Do you mean the commit that changed |
The change in question is python/cpython@49e5740. Actually, I'm not sure if
What kind of tests do you have in mind? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's actually a test called test_route_name
that tests this code.
All good here. Thanks @mgorny :)
But... To be honest... If it was unintended on CPython's side, I'd prefer to wait for them to revert the unintended changes. |
Thanks for this PR. It works nicely as a downstream patch in Fedora Rawhide, which allows me to keep building and updating Starlette. I’ll monitor python/cpython#122087 and drop the downstream patch if this ends up being handled in CPython 3.13.0rc1. |
Looks like CPython is going to fix the issue.
@Kludex, upstream confirmed that:
So I think we should merge this anyway. |
Fix `routing.get_name()` to use the `__name__` attribute only if it is actually present, rather than assuming that all routine and class types have it, and use the fallback to class name otherwise. This is necessary for `functools.partial()` that doesn't have a `__name__` attribute, but is recognized as a routine starting with Python 3.13.0b3. Since for older versions of Python, it would have used the fallback anyway, this doesn't really change the behavior there. Fixes encode#2638
Well... But they are fixing it for |
Yes, they're adding a workaround for Python 3.13. However, it will fail again in 3.14. |
Well... Then let's go. 😅 Thanks @mgorny 🙏 |
Thanks a lot! |
Summary
Fix
routing.get_name()
to use the__name__
attribute only if it is actually present, rather than assuming that all routine and class types have it, and use the fallback to class name otherwise. This is necessary forfunctools.partial()
that doesn't have a__name__
attribute, but is recognized as a routine starting with Python 3.13.0b3. Since for older versions of Python, it would have used the fallback anyway, this doesn't really change the behavior there.Fixes #2638
Checklist