Update FileIO comments, documentation to match implementation
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando i commenti nel codice di FileIO e la documentazione del builtin open() collegata nell’issue, quindi analizza le PR collegate gh-129012, gh-135328, gh-150957, gh-150958 e gh-150959. Il lavoro è completato quando i commenti descrivono il comportamento attuale di read/readall e la documentazione di open() spiega chiaramente buffering=0 e il comportamento relativo alla perdita di dati nelle scritture parziali.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100