From fa9a51e528125d118afbf74e58ec4e3eda88de7c Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 14 Nov 2022 16:21:35 +0200 Subject: [PATCH] Use os.path.dirname() for getting the directory name of a path (#81504) --- homeassistant/util/file.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/util/file.py b/homeassistant/util/file.py index cb5969b3079..06471eaca6a 100644 --- a/homeassistant/util/file.py +++ b/homeassistant/util/file.py @@ -54,11 +54,10 @@ def write_utf8_file( """ tmp_filename = "" - tmp_path = os.path.split(filename)[0] try: # Modern versions of Python tempfile create this file with mode 0o600 with tempfile.NamedTemporaryFile( - mode="w", encoding="utf-8", dir=tmp_path, delete=False + mode="w", encoding="utf-8", dir=os.path.dirname(filename), delete=False ) as fdesc: fdesc.write(utf8_data) tmp_filename = fdesc.name