Skip to content

shutil.make_archive now fails with pathlib.Path object in Python 3.11.0b4 #94844

Closed
@treyhunner

Description

@treyhunner

Bug report

This code works on Python 3.10 and Python 3.11.0a5 but raises a TypeError in Python 3.11.0b4:

from pathlib import Path
from shutil import make_archive
path = Path.cwd().resolve()
make_archive(path, 'zip', path.parent, path.name)

Here's the output I see in Python 3.11.0b4:

>>> from pathlib import Path
>>> from shutil import make_archive
>>> path = Path.cwd().resolve()
>>> make_archive(path, 'zip', path.parent, path.name)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/trey/.pyenv/versions/3.11.0b4/lib/python3.11/shutil.py", line 1130, in make_archive
    filename = func(base_name, base_dir, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trey/.pyenv/versions/3.11.0b4/lib/python3.11/shutil.py", line 977, in _make_zipfile
    zip_filename = base_name + ".zip"
                   ~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

Your environment

  • CPython versions tested on: Python 3.11.0b4
  • Operating system and architecture: 64-bit Ubuntu Linux 20.04

Metadata

Metadata

Labels

3.10only security fixes3.11only security fixes3.12bugs and security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions