Update FileIO comments, documentation to match implementation
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Documentation
Discuss thread: https://discuss.python.org/t/change-open-write-to-guarantee-all-bytes-will-be-written-or-an-exception-will-be-thrown/71082
- FileIO behaves differently than its code comments around
readandreadall. Update the code comments to match current behavior- PEP 475, reads are retried in some cases
.readall()makes multiple system calls by design
- Add documentation to
open()builtin thatbuffering=0, which currently just says "disables buffering") changes how.write()behaves and may result in data loss as a result of a partial write (ex. gh-126606).TextIOandBufferedIO(which are gotten via commonly usedopen('README.rst'),open('README.rst', 'rb')) retry partial writes providing a user a guarantee either all bytes will be written or an exception will be thrown.FileIOis "Raw I/O" and by PEP-3116 design, as documented, and currently implemented does not retry partial writes.- Most the time,
buffering=0currently speeds up writing a file, but it can also result in corrupted files, ex. gh-126606 from using FileIO directly - I would like to try and change the behavior of
buffering=0to use BufferedIO but with a 0 sized buffer, and that is on my roadmap but will be a while (people use the flag for a reason / get benefit!). This will meanopen()always returns an object which implements "Write all or throw exception" behavior. - Add warning / document existing behavior on
open()in the meantime.
Linked PRs
- gh-129012
- gh-135328
- gh-150957
- gh-150958
- gh-150959
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 Kommentare im FileIO-Code und die in der Issue verlinkte Dokumentation zum open()-Builtin zu prüfen, und untersuche anschließend die verlinkten PRs gh-129012, gh-135328, gh-150957, gh-150958 und gh-150959. Als abgeschlossen gilt die Aufgabe, wenn die Kommentare das aktuelle read/readall-Verhalten beschreiben und die open()-Dokumentation buffering=0 sowie das Verhalten des Datenverlusts bei partiellen Schreibvorgängen klar erklärt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100