Skip to content

TarFile.extractall() doesn't properly handle UNC paths #143663

@0xd6cb6d73

Description

@0xd6cb6d73

Bug report

Bug description:

TarFile.extractall() does not perform path normalization before calling os.lstat(). This is an issue on Windows as the resulting path ends us using Windows-style (\\) and unix-style (/) path separators. This results in the following error: OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '\\\\?\\Z:\\extracted\\double-conversion-v3.1.4.tar.gz\\double-conversion-3.1.4/test/cctest'.

from Lib import tarfile


with tarfile.open(r'\\?\Z:\downloads\double-conversion-v3.1.4.tar.gz') as t:
    t.extractall(r'\\?\Z:\extracted\double-conversion-v3.1.4.tar.gz')

CPython versions tested on:

3.13, CPython main branch

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowsstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions