Visitar URL original
bpo-43012: remove `pathlib._Accessor` by barneygale · Pull Request #25701 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move comment to Path._scandir() definition.
  • Loading branch information
barneygale committed Jan 5, 2022
commit c9ffcf90d855e2aaf389ee889c72d797c41a629e
7 changes: 3 additions & 4 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,6 @@ def __init__(self, pat, child_parts, flavour):

def _select_from(self, parent_path, is_dir, exists):
try:
# bpo-24132: a future version of pathlib will support subclassing
# of pathlib.Path to customize how the filesystem is accessed. We
# must honour those customizations here, rather than calling
# os.scandir() directly.
with parent_path._scandir() as scandir_it:
Comment thread
barneygale marked this conversation as resolved.
Outdated
entries = list(scandir_it)
for entry in entries:
Expand Down Expand Up @@ -934,6 +930,9 @@ def iterdir(self):
yield self._make_child_relpath(name)

def _scandir(self):
# bpo-24132: a future version of pathlib will support subclassing of
# pathlib.Path to customize how the filesystem is accessed. This
# includes scandir(), which is used to implement glob().
return os.scandir(self)

def glob(self, pattern):
Expand Down