Skip to content

Raise NotADirectoryError from Path.iterdir - #154

Merged
jaraco merged 4 commits into
jaraco:mainfrom
ShipItAndPray:fix-129-iterdir-notadirectory
May 18, 2026
Merged

jaraco merged 4 commits into
jaraco:mainfrom
ShipItAndPray:fix-129-iterdir-notadirectory

Conversation

@ShipItAndPray

@ShipItAndPray ShipItAndPray commented Apr 27, 2026 •

Copy link
Copy Markdown

Summary

  • make zipp.Path.iterdir() raise NotADirectoryError on non-directories instead of ValueError
  • align the behavior with pathlib.Path.iterdir() and the issue report
  • update the existing path test to assert the directory-specific exception type

Closes #129.

Validation

Autoresearch-style binary gates:

  • E1 baseline repro exists: Path(... / 'file.txt').iterdir() raised ValueError: Can't listdir a file on main
  • E2 regression expectation fails on baseline: the updated test expects NotADirectoryError, so baseline behavior is wrong by exception type
  • E3 regression passes after fix: direct runtime repro now raises NotADirectoryError
  • E4 targeted tests pass:
    • .venv/bin/python -m pytest tests/test_path.py -k 'iterdir_on_file or is_file_missing or subdir_is_dir'
    • .venv/bin/python -m pytest tests/test_path.py -k 'iterdir'
  • E5 broader nearby suite passes:
    • .venv/bin/python -m pytest tests/test_path.py

Notes

This keeps the patch localized to the iterdir() exception path and the existing regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Path.iterdir() raises ValueError on non-directory; should raise NotADirectoryError

3 participants