Update FileIO comments, documentation to match implementation
Đang mở
Chưa có ai nhận issue này.
docs
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách xem xét các chú thích trong mã FileIO và tài liệu về builtin open() được liên kết trong issue, sau đó kiểm tra các PR được liên kết gh-129012, gh-135328, gh-150957, gh-150958 và gh-150959. Công việc được xem là hoàn tất khi các chú thích mô tả hành vi hiện tại của read/readall và tài liệu về open() giải thích rõ buffering=0 cùng hành vi mất dữ liệu khi ghi một phần.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100