Repository navigation
shutil.make_archive should not need to chdir (alternatively: make shutil.make_archive thread-safe) #74696
Description
Activity
Currently shutil.make_archive uses os.chdir, however there's no need for that. Everything that's done could be equally accomplished with path manipulation:
https://github.com/python/cpython/blob/master/Lib/shutil.py#L773-L779
We should switch to using path manipulation in order to make shutil.make_archive thread safe.
(Flag: This is probably a good bug for someone with Python skills interested in contributing to CPython!)
- added3.7 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on May 30, 2017 Unfortunately this is not possible. The signature of functions registered with register_archive_format() doesn't support this.
None of those functions are a public API, so changing them shouldn't be a problem IMO.
Ugh, except via |register_archive_format|. |register_archive_format| could wrap callables passed to it to maintain the current behavior.
It would be nice if there was at least a warning in the docs that make_archive is not thread-safe, and that if you have two threads creating archives that it's extremely likely you'll get erroneous results since the race condition lasts for the entire duration of the archive creation.
Just wasted two hours for this. Can someone really update the documentation of it if this is not going to change.
PR is added here:
#2693314 remaining items
@gpshead I'm +1 to deprecate
register_archive_format()in 3.12 and remove in 𝛑-Py. Can we use this issue for that or should I open a new one?I was going to extend
register_archive_format()by adding support of custom unpackers which supportroot_dir.It can be implemented either by adding a boolean parameter
supports_root_dirinregister_archive_format(), or checking thesupports_root_dirattribute of the unpacker function.Sure, Serhiy. Greg's point is that this functionality looks unused so it's probably an unnecessary support burden.
py7zr provides helpers to be registered in
shutil. Other archiver modules can provide such helpers too or even register them by default. Removingregister_archive_format()andregister_unpack_format()will make other archive formats second-class citizens.I have implemented the second option in #94251. It seems better because does not need a collaboration between the author and users of the custom archiver.
- added a commit that references this issue
on Jun 26, 2022 - added a commit that references this issue
on Oct 6, 2022
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: