Import errors with loo long entry in sys.path or PYTHONPATH in Windows
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
Bug report
Bug description:
Having too long entries in sys.path or PYTHONPATH in Windows will cause different errors in imports. This was first reported on #122170, where there is some useful discussion.
> $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
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-122389
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece pelas reproduções de caminhos longos na issue e inspecione as localizações do traceback de frozen getpath e importlib._bootstrap_external no Windows. Revise a issue #122170 e a PR vinculada gh-122389 para conhecer a direção existente. O trabalho estará concluído quando entradas longas de PYTHONPATH e sys.path não produzirem mais os erros de inicialização ou importação relatados.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- backend, operating-systems
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 25/100