os.walk() silent about non-directory
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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