mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #20876: correctly close temporary file in test.support.fs_is_case_insensitive()
This commit is contained in:
commit
adb351fcea
1 changed files with 9 additions and 10 deletions
|
@ -2134,16 +2134,15 @@ def skip_unless_xattr(test):
|
||||||
|
|
||||||
def fs_is_case_insensitive(directory):
|
def fs_is_case_insensitive(directory):
|
||||||
"""Detects if the file system for the specified directory is case-insensitive."""
|
"""Detects if the file system for the specified directory is case-insensitive."""
|
||||||
base_fp, base_path = tempfile.mkstemp(dir=directory)
|
with tempfile.NamedTemporaryFile(dir=directory) as base:
|
||||||
case_path = base_path.upper()
|
base_path = base.name
|
||||||
if case_path == base_path:
|
case_path = base_path.upper()
|
||||||
case_path = base_path.lower()
|
if case_path == base_path:
|
||||||
try:
|
case_path = base_path.lower()
|
||||||
return os.path.samefile(base_path, case_path)
|
try:
|
||||||
except FileNotFoundError:
|
return os.path.samefile(base_path, case_path)
|
||||||
return False
|
except FileNotFoundError:
|
||||||
finally:
|
return False
|
||||||
os.unlink(base_path)
|
|
||||||
|
|
||||||
|
|
||||||
class SuppressCrashReport:
|
class SuppressCrashReport:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue