summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2024-12-05 21:39:43 (GMT)
committerGitHub <noreply@github.com>2024-12-05 21:39:43 (GMT)
commit8b3cccf3f9508572d85b0044519f2bd5715dacad (patch)
tree9c5e6a23fa26ef59fa0db986ccf9bf4a1bd3a9a2 /Doc
parentf4f530804b9d8f089eba0f157ec2144c03b13651 (diff)
downloadcpython-8b3cccf3f9508572d85b0044519f2bd5715dacad.zip
cpython-8b3cccf3f9508572d85b0044519f2bd5715dacad.tar.gz
cpython-8b3cccf3f9508572d85b0044519f2bd5715dacad.tar.bz2
GH-125413: Revert addition of `pathlib.Path.scandir()` method (#127377)
Remove documentation for `pathlib.Path.scandir()`, and rename the method to `_scandir()`. In the private pathlib ABCs, make `iterdir()` abstract and call it from `_scandir()`. It's not worthwhile to add this method at the moment - see discussion: https://discuss.python.org/t/ergonomics-of-new-pathlib-path-scandir/71721 Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/pathlib.rst29
-rw-r--r--Doc/whatsnew/3.14.rst6
2 files changed, 0 insertions, 35 deletions
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index a42ac1f..4b48880 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -1289,35 +1289,6 @@ Reading directories
raised.
-.. method:: Path.scandir()
-
- When the path points to a directory, return an iterator of
- :class:`os.DirEntry` objects corresponding to entries in the directory. The
- returned iterator supports the :term:`context manager` protocol. It is
- implemented using :func:`os.scandir` and gives the same guarantees.
-
- Using :meth:`~Path.scandir` instead of :meth:`~Path.iterdir` can
- significantly increase the performance of code that also needs file type or
- file attribute information, because :class:`os.DirEntry` objects expose
- this information if the operating system provides it when scanning a
- directory.
-
- The following example displays the names of subdirectories. The
- ``entry.is_dir()`` check will generally not make an additional system call::
-
- >>> p = Path('docs')
- >>> with p.scandir() as entries:
- ... for entry in entries:
- ... if entry.is_dir():
- ... entry.name
- ...
- '_templates'
- '_build'
- '_static'
-
- .. versionadded:: 3.14
-
-
.. method:: Path.glob(pattern, *, case_sensitive=None, recurse_symlinks=False)
Glob the given relative *pattern* in the directory represented by this path,
diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst
index db25c03..b300e34 100644
--- a/Doc/whatsnew/3.14.rst
+++ b/Doc/whatsnew/3.14.rst
@@ -532,12 +532,6 @@ pathlib
(Contributed by Barney Gale in :gh:`73991`.)
-* Add :meth:`pathlib.Path.scandir` to scan a directory and return an iterator
- of :class:`os.DirEntry` objects. This is exactly equivalent to calling
- :func:`os.scandir` on a path object.
-
- (Contributed by Barney Gale in :gh:`125413`.)
-
pdb
---