glob.translate incorrectly treats ***
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
While I could not find relevant manpage or other Unix standard, gitignore states:
Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:
A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth.
A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
Other consecutive asterisks are considered regular asterisks and will match according to the previous rules.
My understanding of the last sentence is that a triple asterisk *** (and any longer) should be treated exactly the same as a single one *, but it is not the case. While close, and definitely neither a double asterisk nor a naive repetition of a single one, it has an incorrect quantifier. It is likely caused because the first * is neither surrounded by path separators, nor by string begin/end.
import glob;
print(glob.translate('*', include_hidden=True, recursive=True))
print(glob.translate('***', include_hidden=True, recursive=True))
Expected behavior:
(?s:[^/]+)\Z
(?s:[^/]+)\Z
Actual behavior:
(?s:[^/]+)\Z
(?s:[^/]*)\Z
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die bereitgestellten glob.translate-Beispiele auszuführen, und untersuche den glob.translate-Einstiegspunkt. Vergleiche die Behandlung von '' und '**' beim rekursiven Matching, füge anschließend Tests für die erwartungsgemäß identischen regulären Ausdrücke hinzu und verifiziere das berichtete Verhalten unter Python 3.13.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 48/100