Commit e3207fe8 authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #20876: correctly close temporary file in test.support.fs_is_case_insensitive()

parent 8c69ecf9
...@@ -2133,7 +2133,8 @@ def skip_unless_xattr(test): ...@@ -2133,7 +2133,8 @@ 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:
base_path = base.name
case_path = base_path.upper() case_path = base_path.upper()
if case_path == base_path: if case_path == base_path:
case_path = base_path.lower() case_path = base_path.lower()
...@@ -2141,8 +2142,6 @@ def fs_is_case_insensitive(directory): ...@@ -2141,8 +2142,6 @@ def fs_is_case_insensitive(directory):
return os.path.samefile(base_path, case_path) return os.path.samefile(base_path, case_path)
except FileNotFoundError: except FileNotFoundError:
return False return False
finally:
os.unlink(base_path)
class SuppressCrashReport: class SuppressCrashReport:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment