Visitar URL original
Tarfile extraction does not work on Windows · Issue #95763 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20250528125123/https://github.com/python/cpython/issues/95763
Skip to content

Tarfile extraction does not work on Windows #95763

Open
@ioah86

Description

@ioah86

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixesOS-windowsstdlibPython modules in the Lib dirtriagedThe issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions