From 8dc556d4204df2cb760e950a68dda050eaee179f Mon Sep 17 00:00:00 2001 From: J0J0 T Date: Mon, 22 Aug 2022 11:23:33 +0200 Subject: [PATCH] convert: playlist: Use syspath() for file read and write operations. --- beets/util/m3u.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beets/util/m3u.py b/beets/util/m3u.py index 3db3f4084..983833afb 100644 --- a/beets/util/m3u.py +++ b/beets/util/m3u.py @@ -16,6 +16,9 @@ """ +from beets.util import syspath + + class EmptyPlaylistError(Exception): """An error that should be raised when a playlist file without media files is saved or loaded. @@ -41,7 +44,7 @@ class M3UFile(): def load(self): """Reads the m3u file from disk and sets the object's attributes. """ - with open(self.path, "r") as playlist_file: + with open(syspath(self.path), "r") as playlist_file: raw_contents = playlist_file.readlines() self.extm3u = True if raw_contents[0] == "#EXTM3U\n" else False for line in raw_contents[1:]: @@ -72,6 +75,6 @@ class M3UFile(): if not self.media_list: raise EmptyPlaylistError contents = header + self.media_list - with open(self.path, "w") as playlist_file: + with open(syspath(self.path), "w") as playlist_file: playlist_file.writelines('\n'.join(contents)) playlist_file.write('\n') # Final linefeed to prevent noeol file.