From f9dfd3460219f17e6757872c511e4d1dd9e34007 Mon Sep 17 00:00:00 2001 From: Johnny Robeson Date: Sat, 2 Jul 2016 02:02:21 -0400 Subject: [PATCH] use py3_path for archive (ZipFile, etc) filenames ZipFile and RarFile both only accept string filenames on py3, not bytestrings. --- beets/importer.py | 4 ++-- test/test_importer.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/beets/importer.py b/beets/importer.py index f3272311f..6a1be6ddc 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -944,7 +944,7 @@ class ArchiveImportTask(SentinelImportTask): return False for path_test, _ in cls.handlers(): - if path_test(path): + if path_test(util.py3_path(path)): return True return False @@ -990,7 +990,7 @@ class ArchiveImportTask(SentinelImportTask): try: extract_to = mkdtemp() - archive = handler_class(self.toppath, mode='r') + archive = handler_class(util.py3_path(self.toppath), mode='r') archive.extractall(extract_to) finally: archive.close() diff --git a/test/test_importer.py b/test/test_importer.py index 29487ec26..07b6680ea 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -30,7 +30,7 @@ from mock import patch from test import _common from test._common import unittest -from beets.util import displayable_path, bytestring_path +from beets.util import displayable_path, bytestring_path, py3_path from test.helper import TestImportSession, TestHelper, has_program, capture_log from beets import importer from beets.importer import albums_in_dir @@ -355,9 +355,9 @@ class NonAutotaggedImportTest(_common.TestCase, ImportHelper): def create_archive(session): - (handle, path) = mkstemp(dir=session.temp_dir) + (handle, path) = mkstemp(dir=py3_path(session.temp_dir)) os.close(handle) - archive = ZipFile(path, mode='w') + archive = ZipFile(py3_path(path), mode='w') archive.write(os.path.join(_common.RSRC, b'full.mp3'), 'full.mp3') archive.close() @@ -414,7 +414,7 @@ class ImportTarTest(ImportZipTest): def create_archive(self): (handle, path) = mkstemp(dir=self.temp_dir) os.close(handle) - archive = TarFile(path, mode='w') + archive = TarFile(py3_path(path), mode='w') archive.add(os.path.join(_common.RSRC, b'full.mp3'), 'full.mp3') archive.close()