Align test/support/os_helper with CPython 3.10

This commit is contained in:
Padraic Fanning
2022-02-10 21:40:08 -05:00
parent 61f8068082
commit e0460235db

View File

@@ -302,7 +302,7 @@ if sys.platform.startswith("win"):
try:
mode = os.lstat(fullname).st_mode
except OSError as exc:
print("os_helper.rmtree(): os.lstat(%r) failed with %s"
print("support.rmtree(): os.lstat(%r) failed with %s"
% (fullname, exc),
file=sys.__stderr__)
mode = 0
@@ -479,6 +479,17 @@ def create_empty_file(filename):
os.close(fd)
@contextlib.contextmanager
def open_dir_fd(path):
"""Open a file descriptor to a directory."""
assert os.path.isdir(path)
dir_fd = os.open(path, os.O_RDONLY)
try:
yield dir_fd
finally:
os.close(dir_fd)
def fs_is_case_insensitive(directory):
"""Detects if the file system for the specified directory
is case-insensitive."""