os.path.relpath() assumes '//' root is equivalent to '/'
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 36k
- Ø Merge
- 1 T. 9 Std.
- Gemergte PRs (30 T.)
- 558
Beschreibung
Bug report
pathlib's Path.relative_to() and os.path.relpath(), the two have different behavior: On Linux os.path.relpath() understands double-slash in path is same as single slash, but Path.relative_to() does not.
For example,
import os
os.path.relpath('//foo/bar', '/foo') # results 'bar'
from pathlib import Path
pathlib.PosixPath('//foo/bar').relative_to('/foo') # raises ValueError
pytest issue https://github.com/pytest-dev/pytest/issues/9894 relates to this.
Your environment
- CPython versions tested on: 3.9.2
- Operating system and architecture: Debian Bullseye
Linked PRs
- gh-103798
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 mit dem Vergleich von os.path.relpath() und pathlib.PosixPath.relative_to() für das Beispiel //foo/bar gegenüber /foo und sieh dir anschließend pytest issue #9894 und den verknüpften PR gh-103798 an. Erledigt ist die Aufgabe, wenn das beabsichtigte Verhalten konsistent geklärt ist und das Beispiel durch relevante Tests abgedeckt wird.
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
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100