Skip to content

Commit e046023

Browse files
committed
Align test/support/os_helper with CPython 3.10
1 parent 61f8068 commit e046023

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

Lib/test/support/os_helper.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def _rmtree_inner(path):
302302
try:
303303
mode = os.lstat(fullname).st_mode
304304
except OSError as exc:
305-
print("os_helper.rmtree(): os.lstat(%r) failed with %s"
305+
print("support.rmtree(): os.lstat(%r) failed with %s"
306306
% (fullname, exc),
307307
file=sys.__stderr__)
308308
mode = 0
@@ -479,6 +479,17 @@ def create_empty_file(filename):
479479
os.close(fd)
480480

481481

482+
@contextlib.contextmanager
483+
def open_dir_fd(path):
484+
"""Open a file descriptor to a directory."""
485+
assert os.path.isdir(path)
486+
dir_fd = os.open(path, os.O_RDONLY)
487+
try:
488+
yield dir_fd
489+
finally:
490+
os.close(dir_fd)
491+
492+
482493
def fs_is_case_insensitive(directory):
483494
"""Detects if the file system for the specified directory
484495
is case-insensitive."""

0 commit comments

Comments
 (0)