Tarfile extraction does not work on Windows

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

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

Đánh giá

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

Hướng nghiên cứu

Bắt đầu với tarfile.extractall và phần lọc members được nêu trong báo cáo, sau đó tái hiện hành vi trên Windows bằng các lệnh docker create và docker export. So sánh việc giải nén với cùng phiên bản Python trên Linux. Hoàn tất khi tệp lưu trữ tar đã xuất có thể được giải nén trên Windows mà không xảy ra lỗi do vượt quá độ sâu đệ quy hoặc vòng lặp vô hạn.

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

Mô tả

3.10 3.11 3.12 OS-windows stdlib triaged type-bug

Using Python 3.10.5, there is a scenario where the extractall function of tarfile is causing an infinite loop for Python on Windows, but not in Linux.

The tar-file where the issue occurred was the one produced by docker export, where a file-system is saved as a tar file. Unfortunately, it is too big to upload here, so I will give some commands to get this file.

> docker create --name "testcontainer" tomcat
> docker export --output="testtomcat.tar" testcontainer

That should produce a file of about 457MB.

Now, using Python 3.10.5 under Windows, the following code-snippet will crash:

import tarfile
with tarfile.open("testtomcat.tar") as tarf:
     members_to_extract = [tar_info for tar_info in tarf.getmembers()
                                           if not tar_info.isdev()]
     tarf.extractall(path="/tmp/foo/", members=members_to_extract)

The error says: maximum recursion depth exceeded while calling a Python object

Your environment

  • CPython versions tested on: Python 3.10.5
  • Operating system and architecture: Windows 11 is where it failed, and it works fine with the same python version in Arch Linux with kernel Linux 5.15.58-2-lts x86_64
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
558

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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 python/cpython

Tất cả issue của python/cpython

Issue tương tự

Thêm issue về Python

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.