Skip to content

Cache None results in LazyProxy - #1354

Closed
Eric3-jp wants to merge 1 commit into
python-babel:masterfrom
Eric3-jp:fix-lazy-proxy-none-cache
Closed

Eric3-jp wants to merge 1 commit into
python-babel:masterfrom
Eric3-jp:fix-lazy-proxy-none-cache

Conversation

@Eric3-jp

Copy link
Copy Markdown

LazyProxy uses None as both the initial cache value and a possible callable result. Consequently a callable returning None runs again on every .value access or truth-value test, even with caching enabled.

Track whether a value has been cached separately from the value itself. Successful None results are now cached, while disabled caching and callable exceptions retain their existing behavior. The regression matrix checks None and other falsey values with caching enabled and disabled, and verifies that construction remains lazy.

Validation on Windows, CPython 3.14.0:

  • Before the implementation change, the None/enabled case fails and the other nine controls pass; afterward all ten pass.
  • After importing the repository's CLDR data, python -X utf8 -m pytest --cov=babel -q: 7,839 passed, 9 skipped, 2 xfailed; 93% total coverage.
  • Ruff 0.14.10, matching the pre-commit pin, passes on both changed files.
  • git diff --check: passed.

Prepared and validated with OpenAI Codex assistance.

@Eric3-jp Eric3-jp closed this by deleting the head repository Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants