python / python/cpython

os.walk() silent about non-directory

Open
#101,420 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

os.walk() silently produces an empty iterator if the argument is not a path to directory:

>>> import os
>>> list(os.walk('./non-existing'))
[]
>>> list(os.walk('./python'))
[]
>>> list(os.walk('/dev/null'))
[]

It can causes bugs like #99203, when a function produces some incorrect result instead of raising an exception.

Linked PRs
  • gh-151734

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the three os.walk() examples from the issue in a CPython checkout and read the related report in #99203. Then inspect linked PR gh-151734 and the os.walk implementation and tests to understand the proposed resolution and what remains to be completed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.