8000 gh-82116: add comment explaining use of `list(scandir_it)` in pathlib. by barneygale · Pull Request #94939 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-82116: add comment explaining use of list(scandir_it) in pathlib. #94939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
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
gh-82116: add comment explaining use of list(scandir_it) in pathlib.
  • Loading branch information
barneygale committed Jul 17, 2022
commit 5116d9f873355b03ec2d1cb41384356362a12fee
4 changes: 4 additions & 0 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ def __init__(self, pat, child_parts, flavour):

def _select_from(self, parent_path, is_dir, exists, scandir):
try:
# We must close the scandir() object before proceeding to
# avoid exhausting file descriptors when globbing deep trees.
with scandir(parent_path) as scandir_it:
entries = list(scandir_it)
for entry in entries:
Expand Down Expand Up @@ -330,6 +332,8 @@ def __init__(self, pat, child_parts, flavour):
def _iterate_directories(self, parent_path, is_dir, scandir):
yield parent_path
try:
# We must close the scandir() object before proceeding to
# avoid exhausting file descriptors when globbing deep trees.
with scandir(parent_path) as scandir_it:
entries = list(scandir_it)
for entry in entries:
Expand Down
0