-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-94844: Add pathlib support to shutil archive management #94846
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 |
Lib/test/test_shutil.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add a class. A single test will suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted; I agree that after the conversion moved into make_archive
frontend, there is no need to explicitly test _make_*
backends.
Lib/shutil.py
Outdated
@@ -1127,6 +1127,7 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0, | |||
if not dry_run: | |||
os.chdir(root_dir) | |||
|
|||
base_name = os.fspath(base_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, amended.
@@ -0,0 +1,2 @@ | |||
:meth:`shutil.make_archive` now accepts any :class:`os.PathLike`. Patch by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]> (cherry picked from commit ed44415) Co-authored-by: Oleg Iarygin <[email protected]>
…honGH-94846) Co-authored-by: Barney Gale <[email protected]> (cherry picked from commit ed44415) Co-authored-by: Oleg Iarygin <[email protected]>
GH-95055 is a backport of this pull request to the 3.11 branch. |
@serhiy-storchaka Thanks for merging. |
Co-authored-by: Barney Gale <[email protected]> (cherry picked from commit ed44415) Co-authored-by: Oleg Iarygin <[email protected]>
Co-authored-by: Barney Gale <[email protected]> (cherry picked from commit ed44415) Co-authored-by: Oleg Iarygin <[email protected]>
Underlying
ZipFile.__init__
casts a path to str anyway:cpython/Lib/zipfile.py
Lines 1270 to 1271 in b03a9e8
so
make_archive
can safely cast its path param to a str as well (including implicit conversion in f-strings).