Skip to content

gh-150885: Remove unused shutil._ensure_directory#150883

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
gaborbernat:deadcode/shutil-ensure-directory
Jun 7, 2026
Merged

gh-150885: Remove unused shutil._ensure_directory#150883
serhiy-storchaka merged 1 commit into
python:mainfrom
gaborbernat:deadcode/shutil-ensure-directory

Conversation

@gaborbernat
Copy link
Copy Markdown
Contributor

@gaborbernat gaborbernat commented Jun 3, 2026

shutil._ensure_directory() arrived in #8295 with shutil.unpack_archive(), where it created the parent directory of each extracted member. The ZIP path-traversal fix in gh-146581 (GH-146591) reworked _unpack_zipfile() to create directories inline and removed the last call to it, so the private helper now has no caller.

Nothing in the repository references the name outside its own definition, found by a word-boundary search across Lib, Modules, Python, Objects, and Include, and a GitHub code search turns up no downstream importer.

_ensure_directory is private and undocumented, so this has no user-facing effect and needs no Misc/NEWS.d entry. The skip news label applies.

Introduced in python#8295 alongside shutil.unpack_archive() as a helper that
created the parent directory of each extracted member.

Orphaned by pythongh-146581 (pythonGH-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.
@gaborbernat gaborbernat force-pushed the deadcode/shutil-ensure-directory branch from 448cb74 to 5de9387 Compare June 3, 2026 19:46
@gaborbernat gaborbernat changed the title gh-150882: Remove unused shutil._ensure_directory gh-150885: Remove unused shutil._ensure_directory Jun 3, 2026
Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@serhiy-storchaka serhiy-storchaka merged commit e5ced1f into python:main Jun 7, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants