Skip to content

Fix startup crash on Python 3.10.0 caused by missing NodeId cache - #15342

Open
Aathi-27 wants to merge 6 commits into
pytest-dev:mainfrom
Aathi-27:fix-nodeid-str-cache-3.10.0
Open

Aathi-27 wants to merge 6 commits into
pytest-dev:mainfrom
Aathi-27:fix-nodeid-str-cache-3.10.0

Conversation

@Aathi-27

@Aathi-27 Aathi-27 commented Nov 5, 2026

Copy link
Copy Markdown

Fixes #15337.

On CPython 3.10.0, NodeId's cached-string attribute isn't initialized because of python/cpython#88815. Calling str() on it raises AttributeError and prevents pytest from starting.

This reads the cache with getattr and a None default, then lets the existing code rebuild it. Added a regression test that simulates the missing attribute, plus a changelog entry.

The relevant suites pass on Python 3.10.0 and 3.14. The regression test fails without the fix on 3.14, and a trivial suite that previously crashed now runs on 3.10.0.

AI assistance: this fix, regression test and PR description were prepared with Instinct.

Improve defensive reading of _str_cache attribute in __str__ method.
Add test for NodeId string representation when cache is missing.
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Nov 5, 2026
Ensure _str_cache attribute exists before deletion to maintain compatibility across interpreter versions.
@khuynh22

Copy link
Copy Markdown

Thanks for addressing this. Could a Pytest maintainer confirm if we can have the fix approved soon, or if Python 3.10.0 remains supported? Also, it might be beneficial to have some dedicated python 3.10.0 ci

@RonnyPfannschmidt RonnyPfannschmidt added the backport 9.2.x backport this PR to 9.2.x branch label Nov 11, 2026

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

Verified on CPython 3.10.0: main crashes, this branch runs. Fix is minimal and correct.


Generated by Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 9.2.x backport this PR to 9.2.x branch bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pytest 9.2.0 regression on Python 3.10.0: NodeId.__str__ raises AttributeError

3 participants