Fix routing.get_name() not to assume all routines have __name__#2648
Fix routing.get_name() not to assume all routines have __name__#2648Kludex merged 1 commit intoKludex:masterfrom
routing.get_name() not to assume all routines have __name__#2648Conversation
|
Can we link the CPython PR here? I don't understand why change this behavior. |
Kludex
left a comment
There was a problem hiding this comment.
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? |
|
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 Kludex#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