]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-125413: Add `pathlib.Path.info` attribute (#127730)
authorBarney Gale <barney.gale@gmail.com>
Sat, 8 Feb 2025 01:16:45 +0000 (01:16 +0000)
committerGitHub <noreply@github.com>
Sat, 8 Feb 2025 01:16:45 +0000 (01:16 +0000)
commit718ab662991214039626db432d60310e0e19a0ac
treefba4538dd72f0eadf6d1a9a93896df18ca73f43a
parenta1417b211f0bb9582b00f7b82d0a43a3bcc9ed05
GH-125413: Add `pathlib.Path.info` attribute (#127730)

Add `pathlib.Path.info` attribute, which stores an object implementing the `pathlib.types.PathInfo` protocol (also new). The object supports querying the file type and internally caching `os.stat()` results. Path objects generated by `Path.iterdir()` are initialised with status information from `os.DirEntry` objects, which is gleaned from scanning the parent directory.

The `PathInfo` protocol has four methods: `exists()`, `is_dir()`, `is_file()` and `is_symlink()`.
Doc/library/pathlib.rst
Doc/whatsnew/3.14.rst
Lib/glob.py
Lib/pathlib/_abc.py
Lib/pathlib/_local.py
Lib/pathlib/_os.py
Lib/pathlib/types.py [moved from Lib/pathlib/_types.py with 57% similarity]
Lib/test/test_pathlib/test_pathlib.py
Lib/test/test_pathlib/test_pathlib_abc.py
Misc/NEWS.d/next/Library/2024-12-10-19-39-35.gh-issue-125413.wOb4yr.rst [new file with mode: 0644]