Fix thumbnail plugin pathlib bug (#3360)

PathlibURI.uri() would fail if given a path as bytes instead of as string.

Co-authored-by: Jacob Pavlock <jtpavlock@gmail.com>
This commit is contained in:
José Albornoz 2020-07-15 22:00:50 -04:00 committed by GitHub
parent 05516f9503
commit dc7e433768
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View file

@ -224,7 +224,7 @@ class PathlibURI(URIGetter):
name = "Python Pathlib"
def uri(self, path):
return PurePosixPath(path).as_uri()
return PurePosixPath(util.py3_path(path)).as_uri()
def copy_c_string(c_string):

View file

@ -139,6 +139,9 @@ New features:
* :doc:`/plugins/lyrics`: Fix a bug in the heuristic for detecting valid
lyrics in the Google source of the lyrics plugin
:bug:`2969`
* :doc:`/plugins/thumbnails`: Fix a bug where pathlib expected a string instead
of bytes for a path.
:bug:`3360`
Fixes:

View file

@ -284,6 +284,15 @@ class ThumbnailsTest(unittest.TestCase, TestHelper):
u'file:///music/%EC%8B%B8%EC%9D%B4')
class TestPathlibURI():
"""Test PathlibURI class"""
def test_uri(self):
test_uri = PathlibURI()
# test it won't break if we pass it bytes for a path
test_uri.uri(b'/')
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)