Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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__
repro.py
$ 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 ===============================================================================================
verify
Re-run: gh repo clone encode/starlette Re-run: cd starlette Re-run: python3.13 --version
fix.md
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).
Production impact:
  • 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

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”
@mgorny · 2024-07-21 · source

Failure Signature (Search String)

  • $ gh repo clone encode/starlette

Error Message

Stack trace
error.txt
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

repro.py
$ 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.

When NOT to use: Do not apply this fix if the application relies on the previous behavior of __name__ being present.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

verify
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

VersionStatus
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.