python / python/cpython

linecache should remember files it failed to read and not try again

Open
#94,436 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.12 performance stdlib
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

When linecache doesn't find a source file or fails to read it due to OSError, SyntaxError or UnicodeDecodeError, it returns an empty result. In subsequent attempts it would try to find and read the file again.

We should instead cache the negative lookup result and bypass the search in future queries.

Linked PRs
  • gh-121224

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the linecache entry point described in the issue and inspect how missing or unreadable files are handled. Confirm that a failed lookup is remembered so later queries bypass the search and return the same empty result; check the linked PR gh-121224 for work already in progress.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.