tarfile.TarFile.errors is initialized for some reason as None even though it really only accepts str
Chưa có ai nhận issue này.
- 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ả
Bug report
Bug description:
See the exact line here: https://github.com/python/cpython/blob/ee57221872ad009df648e22d2f113f907607ec16/Lib/tarfile.py#L1687
After that the errors is used only as string in encode/decode. And is initialized in the dunder init with default errors="surrogateescape".
So perhaps it would be a good idea to use errors="" in #L1687 ? or directly with the default errors="surrogateescape" ?
This was discovered as part of the typeshed, where tarfile.TarFile.errors was added into the allowed list since mypy complained: https://github.com/python/typeshed/blob/2ccc53bb6716463680fcf1d204642c46299b7f88/stdlib/%40tests/stubtest_allowlists/common.txt#L46C1-L46C16
I will add a PR here and to the typeshed if this gets approved.
CPython versions tested on:
3.13
Operating systems tested on:
Windows
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 tại dòng 1687 của Lib/tarfile.py và kiểm tra TarFile initializer cũng như các cách sử dụng errors về sau trong encode/decode. Kiểm tra mục allowlist tương ứng trong typeshed, sau đó xác nhận rằng runtime initialization và typing phù hợp với nhau; cập nhật các thay đổi tương ứng của CPython và typeshed nếu cầ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
- backend
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- 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
- 38/100