You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
make shutil.make_archive always accept pathlib objects #85809
_make_tarball and _make_zipfile on main still contain the offending concatenation operation that fails when given an os.PathLike instance for base_name rather than str. The actual fix seems straightforward (adding an os.fspath call), but additional regression tests would also be desirable.
gh-74421 is the still open meta-issue that covers reviewing the state of shutil support for PathLike objects in general.
#94844 (comment) mentions the make_archive currently partially supports Pathlib.path albeit only if root_dir is supplied (undocumented). Guido van Rossum's suggestion is we address the issue for case when root_dir is None, albeit with light documentation and brief tests.
As @ncoghlan suggests above, os.fspath indeed offers a straightforward fix which allowed me to implement the solution including tiny documentation updates and tests.
Since the linked PR is 5+ years old, would it be okay for me to proceed with a fresh PR introducing path-like object support for make_archive + light tests and documentation?
Activity
graingert commentedon Aug 26, 2020
see also https://bugs.python.org/issue23241
[-]make shutil.make_archive always accepts pathlib objects[/-][+]make shutil.make_archive always accept pathlib objects[/+][-]make shutil.make_archive always accepts pathlib objects[/-][+]make shutil.make_archive always accept pathlib objects[/+]1 remaining item
ncoghlan commentedon Jun 4, 2024
_make_tarballand_make_zipfileon main still contain the offending concatenation operation that fails when given anos.PathLikeinstance forbase_namerather thanstr. The actual fix seems straightforward (adding an os.fspath call), but additional regression tests would also be desirable.gh-74421 is the still open meta-issue that covers reviewing the state of
shutilsupport for PathLike objects in general.tadejmagajna commentedon Jan 6, 2026
This is still generally relevant in 3.14.2:
#94844 (comment) mentions the
make_archivecurrently partially supportsPathlib.pathalbeit only ifroot_diris supplied (undocumented). Guido van Rossum's suggestion is we address the issue for case whenroot_diris None, albeit with light documentation and brief tests.As @ncoghlan suggests above,
os.fspathindeed offers a straightforward fix which allowed me to implement the solution including tiny documentation updates and tests.Since the linked PR is 5+ years old, would it be okay for me to proceed with a fresh PR introducing path-like object support for
make_archive+ light tests and documentation?merwok commentedon Jan 7, 2026
Please ask on the PR if the author wants to update it
tadejmagajna commentedon Jan 8, 2026
Thank you. Done, the author closed the issue.
I shortly plan to open a new PR with the following changes:
base_nameparameter inmake_archiveusingos.fspath(other params are supported already)FakePath(the favored option to usingPathlib.pathin tests directly)In case of any concerns about my proposed approach, please let me know.
pythongh-85809: Ensure shutil.make_archive supports path-like objects
Merge branch 'main' into pythongh-85809-make-archive-pathlib-support
gh-85809: Ensure shutil.make_archive accepts path-like objects in all…
pythongh-85809: Ensure shutil.make_archive accepts path-like objects …
pythongh-85809: Ensure shutil.make_archive accepts path-like objects …