◐ Shell
clean mode source ↗

GH-125413: Add `pathlib.Path.info` attribute by barneygale · Pull Request #127730 · python/cpython

When a path object is generated by `PathBase.iterdir()`, then its `_info`
attribute now stores a `os.DirEntry`-like object that can be used to query
the file type. This removes any need for a `_scandir()` method.

Currently the `_info` attribute is private and only guaranteed to be
populated in paths from `iterdir()`. Later on, I'm hoping to rename it to
`info` and ensure that it's populated for all kinds of paths (this probably
involves adding a `pathlib.FileInfo` class.) In the pathlib ABCs, `info`
will replace `stat()` as the lowest-level abstract file status querying
mechanism.

@barneygale barneygale changed the title GH-125413: pathlib ABCs: replace _scandir() with _info GH-125413: pathlib ABCs: replace _scandir() with _status

Dec 9, 2024

@barneygale

@barneygale barneygale changed the title GH-125413: pathlib ABCs: replace _scandir() with _status GH-125413: Add pathlib.Path.status attribute

Dec 9, 2024

@barneygale

@barneygale barneygale changed the title GH-125413: Add pathlib.Path.status attribute GH-125413: Add pathlib.Path.info attribute

Dec 21, 2024

@barneygale

encukou

Co-authored-by: Petr Viktorin <encukou@gmail.com>

@barneygale