glob.translate incorrectly matches path separator in character ranges
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:
Description
The glob.translate function in Python 3.13 doesn't properly handle path separators when they're included in character ranges. According to the documentation, "wildcards do not match path separators," but this isn't enforced for character ranges that include the path separator.
Expected behavior
Character ranges in glob patterns should not match path separators, consistent with the behavior of single character wildcards (?) and the documented behavior of the module.
Actual behavior
Character ranges that include the path separator (e.g., [%-0] which includes the / character) will match the path separator, contradicting the documented behavior.
Code to reproduce
import glob
import re
# Proper behavior with ? wildcard
r1 = re.compile(glob.translate('a?c', seps=['/']))
print(r1) # (?s:a[^/]c)\Z
print(r1.match('abc')) # match object
print(r1.match('a/c')) # None, correctly doesn't match path separator
# Incorrect behavior with character range
r2 = re.compile(glob.translate('a[%-0]c', seps=['/']))
print(r2) # (?s:a[%-0]c)\Z
print(r2.match('a0c')) # match object
print(r2.match('a/c')) # match object, incorrectly matches path separator
### CPython versions tested on:
3.13
### Operating systems tested on:
_No response_
Linked PRs
- gh-130989
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 com a reprodução de glob.translate na issue, comparando os padrões gerados para ? e intervalos de caracteres quando seps=['/']. Considera-se concluído quando os intervalos de caracteres não corresponderem mais aos separadores de caminho e o comportamento documentado estiver coberto por um teste de regressão; observe que o PR vinculado gh-130989 indica que o trabalho já está em andamento.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- tooling
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 25/100