Skip to content

Commit

Permalink
handle bytes in a py3 compatible way in confit
Browse files Browse the repository at this point in the history
This applies to Subview and Filename.

However, the Filename support isn't complete, since we can't
implicitly convert bytes to strings in py3. Confit doesn't
seem to have a way to handle this.
  • Loading branch information
Johnny Robeson committed Jun 18, 2016
1 parent da5fb85 commit 2669b35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions beets/util/confit.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,11 @@ def __init__(self, parent, key):
self.name += '.'
if isinstance(self.key, int):
self.name += u'#{0}'.format(self.key)
elif isinstance(self.key, BASESTRING):
if isinstance(self.key, bytes):
self.name += self.key.decode('utf8')
else:
elif isinstance(self.key, (bytes, BASESTRING)):
if isinstance(self.key, STRING):
self.name += self.key
else:
self.name += self.key.decode('utf8')
else:
self.name += repr(self.key)

Expand Down Expand Up @@ -1341,7 +1341,7 @@ def resolve_relative_to(self, view, template):

def value(self, view, template=None):
path, source = view.first()
if not isinstance(path, BASESTRING):
if not isinstance(path, (bytes, BASESTRING)):
self.fail(
u'must be a filename, not {0}'.format(type(path).__name__),
view,
Expand Down

0 comments on commit 2669b35

Please sign in to comment.