GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-150885: Remove unused shutil._ensure_directory by gaborbernat · Pull Request #150883 · python/cpython

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Jun 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gaborbernat
gaborbernat requested a review from giampaolo as a code owner June 3, 2026 19:41
@bedevere-app bedevere-app Bot mentioned this pull request Jun 3, 2026
Remove private stdlib helpers orphaned by past removals #150882
Closed
@bedevere-app bedevere-app Bot added the awaiting review label Jun 3, 2026
@gaborbernat
pythongh-150885: Remove unused shutil._ensure_directory
5de9387
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
@bedevere-app bedevere-app Bot mentioned this pull request Jun 3, 2026
Remove unused private function shutil._ensure_directory #150885
Closed
serhiy-storchaka
serhiy-storchaka approved these changes Jun 7, 2026
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

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.

LGTM. 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Jun 7, 2026
@serhiy-storchaka serhiy-storchaka added the skip news label Jun 7, 2026
@serhiy-storchaka
serhiy-storchaka merged commit e5ced1f into python:main Jun 7, 2026
55 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Jun 7, 2026
philthompson10 pushed a commit to philthompson10/cpython that referenced this pull request Jun 17, 2026
@gaborbernat @philthompson10
pythongh-150885: Remove unused shutil._ensure_directory (pythonGH-150883
77b5cd3
)

No longer used after pythongh-146581 (pythonGH-146591).
@gaborbernat
gaborbernat deleted the deadcode/shutil-ensure-directory branch October 3, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@giampaolo giampaolo Awaiting requested review from giampaolo giampaolo is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@gaborbernat @serhiy-storchaka
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.