Skip to content

os.walk() silent about non-directory #101420

Open
@serhiy-storchaka

Description

@serhiy-storchaka

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions