python / python/cpython

Open() on path that exceeds 248 char limit results in "FileNotFoundError: [Errno 2] No such file or directory"

Offen
#99,954 7 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

OS-windows type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
36k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Bug report

Attempting to open or appending paths to sys.path with paths that length exceed the 248 character limit results in incorrect errors. In the case of opening paths that exceeded the limit, rather than an error pointing to the path length being exceeded we see a file not found. A similar error handling issue is prevalent with appending paths that exceed the limit to sys.path. In this case when trying to access the module you will receive a module not found error. I am now aware the path limit can be disabled on installation or later but these false flags led me astray while debugging.

Reproduction Steps:

  • Create a text file whose path exceeds 248 characters
  • Attempt to read/write from that file
    or
  • Create a Python module whose path exceeds 248 characters
  • Attempt to import that module from an external directory by appending the path to sys.path

Environment

  • CPython versions tested on: 3.10.4
  • Operating system and architecture: Windows x64

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, das gemeldete Verhalten unter Windows x64 mit Python 3.10.4 zu reproduzieren: Öffne eine Datei, deren Pfad mehr als 248 Zeichen umfasst, und teste anschließend den Import eines Moduls aus einem überlangen Pfad, der an sys.path angehängt wurde. Verfolge die Fehler beim Öffnen und Importieren zurück, um festzustellen, wo die Längenbedingung verloren geht. Als abgeschlossen gilt die Aufgabe, wenn beide Fälle einen genauen Fehler zur Pfadlänge anstelle von FileNotFoundError oder ModuleNotFoundError melden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
operating-systems
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.