From de3eedc033ed07be000bba446cd3c3c5dfcd282f Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 27 Dec 2021 13:51:42 -0800 Subject: [PATCH] Use bytes for destination base name This is mostly "defensive programming": clients *should* only call this on bytestring paths, but just in case this gets called on a Unicode string path, we should now not crash. --- beets/util/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 9f96d4561..8fd196359 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -496,8 +496,9 @@ def move(path, dest, replace=False): os.replace(path, dest) except OSError: # Copy the file to a temporary destination. + base = os.path.basename(bytestring_path(dest)) tmp = tempfile.NamedTemporaryFile(suffix=b'.beets', - prefix=b'.' + os.path.basename(dest), + prefix=b'.' + base, dir=os.path.dirname(dest), delete=False) try: