Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`fileno` not available on `ZstdDecompressionReader`

Đang mở
#212 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu với các typing stub được cung cấp và entry point ZstdDecompressionReader, sau đó tái hiện ví dụ subprocess.run từ issue. Xác định và kiểm thử hành vi fileno() được dự định, bao gồm khả năng xảy ra ngoại lệ kiểu StringIO, để reader không còn mâu thuẫn với interface BinaryIO.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

According to the shipped typing stubs, ZstdDecompressionReader implements the typing.BinaryIO interface.

Unfortunately, it lacks the fileno() method that is promised by BinaryIO so this is a bit of a lie.
This breaks when trying to do something like:

>>> f = open('foo.zstd', 'rb')
>>> d = zstandard.ZstdDecompressor()
>>> g = d.stream_reader(f)
>>> subprocess.run(['cat'], stdin = g)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/spaans/.pyenv/versions/3.12.1/lib/python3.12/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/spaans/.pyenv/versions/3.12.1/lib/python3.12/subprocess.py", line 992, in __init__
    errread, errwrite) = self._get_handles(stdin, stdout, stderr)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/spaans/.pyenv/versions/3.12.1/lib/python3.12/subprocess.py", line 1708, in _get_handles
    p2cread = stdin.fileno()
              ^^^^^^^^^^^^
AttributeError: 'zstd.ZstdDecompressionReader' object has no attribute 'fileno'

Note that StringIO in the standard library also doesn't support fileno, but has instead chosen to raise an Exception when it is used like this, so a possible solution could be to just mimic that behaviour.

Ngôn ngữ chính
C
Star
641
Fork
117
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của indygreg/python-zstandard

Tất cả issue của indygreg/python-zstandard

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.