Update FileIO comments, documentation to match implementation
Abierto
Nadie ha tomado este issue todavía.
docs
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza revisando los comentarios del código de FileIO y la documentación del builtin open() enlazada en el issue; después, inspecciona los PR enlazados gh-129012, gh-135328, gh-150957, gh-150958 y gh-150959. Se considera terminado cuando los comentarios describan el comportamiento actual de read/readall y la documentación de open() explique claramente buffering=0 y el comportamiento de pérdida de datos en escrituras parciales.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- documentation
- Tipo de issue
- Documentación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100