Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
Description
Bug report
Bug description:
I noticed this via Hypothesis' pretty-printer forlambda
functions, and tracked the divergence through theinspect
module tolinecache
:
importlinecachedeftest():print(linecache.cache["<string>"])# expected to raise KeyErrorassertFalse
If I run this snippet withpython3.13 -Wignore -m pytest repro.py
, or any older Python version, you'll get the expectedKeyError
. But if I append-n2
to the command, it prints(44, None, ['import sys;exec(eval(sys.stdin.readline()))\n'], '<string>')
!
(python3.13 -m pip install pytest pytest-xdist
will get the dependencies for this)
That's thepopen
bootstrap line fromexecnet
, which handles running code across multiple processes forpytest-xdist
. At this point I've foundlinecache.cache.pop("<string>", None)
to be an acceptable workaround, and since I don't have any particular knowledge of either the CPython or execnet code that's as far as I investigated.
CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13
Operating systems tested on:
Linux
Linked PRs
- gh-117174: Add a new route in linecache to fetch interactive source code #117500
- gh-112730: Respect tests that require environment variables with no-colorize fixes #118288
- [3.13] gh-117174: Add a new route in linecache to fetch interactive source code (GH-117500) #131060
- gh-117174: Adapt test_multiple_statements_fail_early now that we have always source #131065
- gh-117174: Fix reference leak and gdb tests #131095
- [3.13] gh-117174: Fix reference leak and gdb tests (GH-131095) #131120
- gh-117174: Skip test_gdb if Python is built with LTO #131143
- gh-117174: Adapt
test_multiple_statements_fail_early
to new REPL behavior (follow-up gh-131065) #131836 - [3.13] gh-117174: Adapt
test_multiple_statements_fail_early
to new REPL behavior (follow-up gh-131065) (GH-131836) #131841 - [3.13] gh-117174: Adapt test_multiple_statements_fail_early now that we have always source (GH-131065) #131850