mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 19:12:40 +01:00
Smartplaylist: don't utf8-encode the name
A Template expression expects an unicode, not an utf8-encoded string. Add a test for that.
This commit is contained in:
parent
6408904a8c
commit
0d1fa80651
2 changed files with 11 additions and 2 deletions
|
|
@ -76,11 +76,10 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
items.extend(_items_for_query(lib, playlist['query'], False))
|
||||
|
||||
m3us = {}
|
||||
basename = playlist['name'].encode('utf8')
|
||||
# As we allow tags in the m3u names, we'll need to iterate through
|
||||
# the items and generate the correct m3u file names.
|
||||
for item in items:
|
||||
m3u_name = item.evaluate_template(basename, True)
|
||||
m3u_name = item.evaluate_template(playlist['name'], True)
|
||||
if m3u_name not in m3us:
|
||||
m3us[m3u_name] = []
|
||||
item_path = item.path
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# -*- coding: utf8 -*-
|
||||
# This file is part of beets.
|
||||
# Copyright 2015, Adrian Sampson.
|
||||
#
|
||||
|
|
@ -14,6 +15,8 @@
|
|||
|
||||
"""Tests for template engine.
|
||||
"""
|
||||
import warnings
|
||||
|
||||
from _common import unittest
|
||||
from beets.util import functemplate
|
||||
|
||||
|
|
@ -207,6 +210,13 @@ class ParseTest(unittest.TestCase):
|
|||
self._assert_call(arg_parts[0], u"bar", 1)
|
||||
self.assertEqual(list(_normexpr(arg_parts[0].args[0])), [u'baz'])
|
||||
|
||||
def test_fail_on_utf8(self):
|
||||
parts = u'é'.encode('utf8')
|
||||
warnings.simplefilter("ignore")
|
||||
with self.assertRaises(UnicodeDecodeError):
|
||||
functemplate._parse(parts)
|
||||
warnings.simplefilter("default")
|
||||
|
||||
|
||||
class EvalTest(unittest.TestCase):
|
||||
def _eval(self, template):
|
||||
|
|
|
|||
Loading…
Reference in a new issue