-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interpreter exits on Windows due to ValueError raised in linecache.py #122170
Comments
I'm surprised that |
I have one ready. |
Oh I was just going to push it now xD Go for yours then, I'll review it. |
Yours is much more complete and polished, is it OK if I close mine? |
Err... it's up to you. |
I'll close it, I'd rather have code of higher quality in the standard library than code I wrote :) |
For some reason, code was added to the Lines 1331 to 1336 in 2c1b1e7
Lines 1398 to 1403 in 2c1b1e7
|
I get a different error when using the reproducer on Linux:
CC @picnixz, this might be a separate issue. This still occurs on both PRs. |
That's #122145. |
Which is fixed by #122161 |
@eryksun I see the ValueError was implemented in #118355, which is recent enough. However, I think that |
The issue is with the If long paths are enabled at the system level (via the "LongPathsEnabled" registry value in Windows 10+), then the legacy DOS If long paths are disabled or not supported (i.e. prior to Windows 10), then pathnames that aren't prefixed by "\\?\" are limited to |
I'll file an issue to summarize what you told me (and to make the discussion distinct from this issue). If we were to patch the |
I believe that would also fix two minor related issues I've found (posting here so I don't forget about them): > $Env:PYTHONPATH="a" * 33000
> py -3.13
Exception ignored in running getpath:
Traceback (most recent call last):
File "<frozen getpath>", line 668, in <module>
OSError: failed to make path absolute
Fatal Python error: error evaluating path
Python runtime state: core initialized
Current thread 0x00005a8c (most recent call first):
<no Python frame> >>> import sys
>>> sys.path.insert(0, "a" * 33000)
>>> import email
Traceback (most recent call last):
File "<frozen importlib._bootstrap_external>", line 1512, in _path_importer_cache
KeyError: 'aaaaaaaaaaaaaaaaaaaaaaaa[...]aaaaaaaaaa'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<python-input-6>", line 1, in <module>
import email
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1322, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1262, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1555, in find_spec
File "<frozen importlib._bootstrap_external>", line 1527, in _get_spec
File "<frozen importlib._bootstrap_external>", line 1514, in _path_importer_cache
File "<frozen importlib._bootstrap_external>", line 1490, in _path_hooks
File "<frozen importlib._bootstrap_external>", line 1714, in path_hook_for_FileFinder
File "<frozen importlib._bootstrap_external>", line 173, in _path_isdir
File "<frozen importlib._bootstrap_external>", line 158, in _path_is_mode_type
File "<frozen importlib._bootstrap_external>", line 152, in _path_stat
ValueError: stat: path too long for Windows |
Actually, I probably found another bug in linecache where requesting a filename with null bytes makes it fail: $ ./python -c 'import linecache;linecache.getlines("a\x00bc")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
import linecache;linecache.getlines("a\x00bc")
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/lib/python/cpython/Lib/linecache.py", line 41, in getlines
return updatecache(filename, module_globals)
File "/lib/python/cpython/Lib/linecache.py", line 100, in updatecache
stat = os.stat(fullname)
ValueError: stat: embedded null character in path but linecache is not supposed to fail =/. |
(So the PR is still correct, would not be fixed even if we change the |
…ythonGH-122176) (cherry picked from commit 7a6d4cc) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…ythonGH-122176) (cherry picked from commit 7a6d4cc) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Now that the PRs have been merged, I think this specific issue can be closed. It remains to fix the other issue at the level of imports and |
For the record, while I think it's okay for So I'm not going to insist on reverting anything here, but I do intend to hold up further changes until they've been properly considered. |
Bug report
Bug description:
It's possible to make the interpreter exit on Windows in 3.13.0b4 and main due to
ValueError: stat: path too long for Windows
being raised byos.stat()
inupdatecache
in linecache.py when trying to print a traceback:CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Windows
Linked PRs
os.stat
for too long filename on Windows #122175ValueError
raised byos.stat
inlinecache
#122176The text was updated successfully, but these errors were encountered: