From 5de9387355972069dd7f9a19524a15b1e9e43c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Wed, 3 Jun 2026 11:32:49 -0700 Subject: [PATCH] gh-150885: 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. --- Lib/shutil.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Lib/shutil.py b/Lib/shutil.py index c8d02bbaeb80b4..52195b244b29e0 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -1307,12 +1307,6 @@ def unregister_unpack_format(name): """Removes the pack format from the registry.""" del _UNPACK_FORMATS[name] -def _ensure_directory(path): - """Ensure that the parent directory of `path` exists""" - dirname = os.path.dirname(path) - if not os.path.isdir(dirname): - os.makedirs(dirname) - def _unpack_zipfile(filename, extract_dir): """Unpack zip `filename` to `extract_dir` """