The Fix
Upgrade to version 0.38.2 or later.
Based on closed Kludex/starlette issue #2638 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -99,9 +99,7 @@ async def app(scope: Scope, receive: Receive, send: Send) -> None:
def get_name(endpoint: typing.Callable[..., typing.Any]) -> str:
- if inspect.isroutine(endpoint) or inspect.isclass(endpoint):
- return endpoint.__name__
- return endpoint.__class__.__name__
$ gh repo clone encode/starlette
$ cd starlette
$ python3.13 --version
Python 3.13.0b3
$ python3.13 -m venv _e
$ . _e/bin/activate
(_e) $ pip install -r requirements.txt
(_e) $ pip install -e .
(_e) $ python -m pytest
_e/lib64/python3.13/site-packages/trio/_path.py:164: in generate_forwards
raise TypeError(attr_name, type(attr))
E TypeError: ('parser', <class 'module'>)
(_e) $ pip install --upgrade trio
(_e) $ python -m pytest
==================================================================================================== ERRORS ====================================================================================================
____________________________________________________________________________________ ERROR collecting tests/test_routing.py ____________________________________________________________________________________
tests/test_routing.py:135: in <module>
Route("/", endpoint=functools.partial(partial_endpoint, "foo")),
starlette/routing.py:227: in __init__
self.name = get_name(endpoint) if name is None else name
starlette/routing.py:103: in get_name
return endpoint.__name__
E AttributeError: 'functools.partial' object has no attribute '__name__'. Did you mean: '__ne__'?
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================================================== 1 error in 0.64s ===============================================================================================
Re-run: gh repo clone encode/starlette
Re-run: cd starlette
Re-run: python3.13 --version
Option A — Upgrade to fixed release\nUpgrade to version 0.38.2 or later.\nWhen NOT to use: Do not apply this fix if the application relies on the previous behavior of __name__ being present.\n\n
Why This Fix Works in Production
- Trigger: $ gh repo clone encode/starlette
- Mechanism: Fixes the issue where `routing.get_name()` assumes all routines have a `__name__` attribute, which is not the case for `functools.partial()` in Python 3.13.0b3.
- Why the fix works: Fixes the issue where `routing.get_name()` assumes all routines have a `__name__` attribute, which is not the case for `functools.partial()` in Python 3.13.0b3. (first fixed release: 0.38.2).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Shows up under Python 3.13.0 in real deployments (not just unit tests).
- Surfaces as: $ gh repo clone encode/starlette
Proof / Evidence
- GitHub issue: #2638
- Fix PR: https://github.com/kludex/starlette/pull/2648
- Fix commit: https://github.com/kludex/starlette/commit/07427f86474b15d648497014eb19c41f01317f15
- First fixed release: 0.38.2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.24
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“This is according to the documentation: > partial objects are like function objects in that they are callable, weak referenceable, and can have attributes”
Failure Signature (Search String)
- $ gh repo clone encode/starlette
Error Message
Stack trace
Error Message
-------------
$ gh repo clone encode/starlette
$ cd starlette
$ python3.13 --version
Python 3.13.0b3
$ python3.13 -m venv _e
$ . _e/bin/activate
(_e) $ pip install -r requirements.txt
(_e) $ pip install -e .
(_e) $ python -m pytest
_e/lib64/python3.13/site-packages/trio/_path.py:164: in generate_forwards
raise TypeError(attr_name, type(attr))
E TypeError: ('parser', <class 'module'>)
(_e) $ pip install --upgrade trio
(_e) $ python -m pytest
==================================================================================================== ERRORS ====================================================================================================
____________________________________________________________________________________ ERROR collecting tests/test_routing.py ____________________________________________________________________________________
tests/test_routing.py:135: in <module>
Route("/", endpoint=functools.partial(partial_endpoint, "foo")),
starlette/routing.py:227: in __init__
self.name = get_name(endpoint) if name is None else name
starlette/routing.py:103: in get_name
return endpoint.__name__
E AttributeError: 'functools.partial' object has no attribute '__name__'. Did you mean: '__ne__'?
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
... (truncated) ...
Minimal Reproduction
$ gh repo clone encode/starlette
$ cd starlette
$ python3.13 --version
Python 3.13.0b3
$ python3.13 -m venv _e
$ . _e/bin/activate
(_e) $ pip install -r requirements.txt
(_e) $ pip install -e .
(_e) $ python -m pytest
_e/lib64/python3.13/site-packages/trio/_path.py:164: in generate_forwards
raise TypeError(attr_name, type(attr))
E TypeError: ('parser', <class 'module'>)
(_e) $ pip install --upgrade trio
(_e) $ python -m pytest
==================================================================================================== ERRORS ====================================================================================================
____________________________________________________________________________________ ERROR collecting tests/test_routing.py ____________________________________________________________________________________
tests/test_routing.py:135: in <module>
Route("/", endpoint=functools.partial(partial_endpoint, "foo")),
starlette/routing.py:227: in __init__
self.name = get_name(endpoint) if name is None else name
starlette/routing.py:103: in get_name
return endpoint.__name__
E AttributeError: 'functools.partial' object has no attribute '__name__'. Did you mean: '__ne__'?
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================================================== 1 error in 0.64s ===============================================================================================
Environment
- Python: 3.13.0
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.38.2 or later.
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/kludex/starlette/pull/2648
First fixed release: 0.38.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if the application relies on the previous behavior of __name__ being present.
Verify Fix
Re-run: gh repo clone encode/starlette
Re-run: cd starlette
Re-run: python3.13 --version
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 0.38.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.