Skip to content

Commit 448cb74

Browse files
committed
gh-150882: Remove unused shutil._ensure_directory
Introduced in #8295 alongside shutil.unpack_archive() as a helper that created the parent directory of each extracted member. Orphaned by gh-146581 (GH-146591), the ZIP path-traversal fix, which reworked _unpack_zipfile() to create directories inline and deleted the last _ensure_directory(targetpath) call site in the same change. Since then the private helper has had no caller: a word-boundary search across Lib, Modules, Python, Objects and Include finds zero references outside its own definition, and a GitHub code search finds no downstream importers.
1 parent 7a468a1 commit 448cb74

1 file changed

Lines changed: 0 additions & 6 deletions

File tree

Lib/shutil.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,12 +1307,6 @@ def unregister_unpack_format(name):
13071307
"""Removes the pack format from the registry."""
13081308
del _UNPACK_FORMATS[name]
13091309

1310-
def _ensure_directory(path):
1311-
"""Ensure that the parent directory of `path` exists"""
1312-
dirname = os.path.dirname(path)
1313-
if not os.path.isdir(dirname):
1314-
os.makedirs(dirname)
1315-
13161310
def _unpack_zipfile(filename, extract_dir):
13171311
"""Unpack zip `filename` to `extract_dir`
13181312
"""

0 commit comments

Comments
 (0)