gh-94844: Add pathlib support to shutil archive management#94846
Conversation
|
|
|
@barneygale Thank you, addressed. |
|
Could you call |
|
Fixed; I quiet misunderstood first. Currently I put the conversion after |
|
Could you remove the changes to |
| class TestPathlibPathArchives(_ArchiveTests, unittest.TestCase): | ||
|
|
||
| def _make_archive_with_path(self, path, /, *args, **kwargs): | ||
| return make_archive(pathlib.Path(path), *args, **kwargs) | ||
|
|
||
| _make_archive = _make_archive_with_path |
There was a problem hiding this comment.
No need to add a class. A single test will suffice.
There was a problem hiding this comment.
Reverted; I agree that after the conversion moved into make_archive frontend, there is no need to explicitly test _make_* backends.
| if not dry_run: | ||
| os.chdir(root_dir) | ||
|
|
||
| base_name = os.fspath(base_name) |
There was a problem hiding this comment.
Please do it only if root_dir is not None, and only if support_root_dir is true (because os.path.abspath() already does the work).
It is an undocumented behavior and we do not want to introduce a new official feature in a bugfix release.
| @@ -0,0 +1,2 @@ | |||
| :meth:`shutil.make_archive` now accepts any :class:`os.PathLike`. Patch by | |||
There was a problem hiding this comment.
It was undocumented behavior, and we do not yet guarantee it in future versions, so no NEWS entry is needed.
There was a problem hiding this comment.
Done; could you add skip-news label please?
|
Thanks @arhadthedev for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10. |
|
Thanks @arhadthedev for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
|
GH-95054 is a backport of this pull request to the 3.10 branch. |
…honGH-94846) Co-authored-by: Barney Gale <barney.gale@gmail.com> (cherry picked from commit ed44415) Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
…honGH-94846) Co-authored-by: Barney Gale <barney.gale@gmail.com> (cherry picked from commit ed44415) Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
|
GH-95055 is a backport of this pull request to the 3.11 branch. |
|
@serhiy-storchaka Thanks for merging. |
Underlying
ZipFile.__init__casts a path to str anyway:cpython/Lib/zipfile.py
Lines 1270 to 1271 in b03a9e8
so
make_archivecan safely cast its path param to a str as well (including implicit conversion in f-strings).