gh-85809: Ensure shutil.make_archive accepts path-like objects in all cases#143668
gh-85809: Ensure shutil.make_archive accepts path-like objects in all cases#143668tadejmagajna wants to merge 5 commits intopython:mainfrom
Conversation
Support for path-like objects such as `Pathlib.path` in `shutil.make_archive`. The change ensures path-like support for all parameters regardless of input. Added lightweight tests and updated documentation including examples.
|
@serhiy-storchaka nicely described the suggested approach in #94844 (comment). Wondering if it is possible get a PR review for this. |
Misc/NEWS.d/next/Library/2026-01-10-22-58-30.gh-issue-85809.0eW4wt.rst
Outdated
Show resolved
Hide resolved
serhiy-storchaka
left a comment
There was a problem hiding this comment.
I just tested -- directory descriptor is not supported as root_dir. So we do not need to worry about this.
As for the test -- currently it only tests that the zip archiver supports path-like arguments. We need something like test_make_archive_cwd_default, test_make_archive_cwd and test_make_archive_cwd_supports_root_dir to test format independent support. Register temporary a mock archiver, call make_archive() with path-like objects, and check what was passed to the archiver.
|
Thank you! Added the format-independent tests using the mock archiver pattern. Covered all cases aside from Also added |
|
Updated the branch with latest |
This change ensures
shutil.make_archiveaccepts path-like objects such asPathlib.pathfor all parameters regardless of input. Includes lightweight tests and updated documentation with refreshed examples.While
shutil.make_archivedid supportPathlib.pathinputs in some cases, this behavior was undocumented, untested and resulted in an exception ifroot_dirwasNone. This case is well described in #94844 (comment).This PR addresses the above issue following this suggested approach.
📚 Documentation preview 📚: https://cpython-previews--143668.org.readthedocs.build/