mirror of
https://github.com/beetbox/beets.git
synced 2026-01-04 15:03:22 +01:00
Always use custom formatter for formatting hook commands
This commit is contained in:
parent
80f4f0a0f2
commit
9bb6c29d22
2 changed files with 4 additions and 8 deletions
|
|
@ -18,7 +18,6 @@ from __future__ import division, absolute_import, print_function
|
|||
|
||||
import string
|
||||
import subprocess
|
||||
import six
|
||||
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.util import shlex_split, arg_encoding
|
||||
|
|
@ -46,10 +45,8 @@ class CodingFormatter(string.Formatter):
|
|||
|
||||
See str.format and string.Formatter.format.
|
||||
"""
|
||||
try:
|
||||
if isinstance(format_string, bytes):
|
||||
format_string = format_string.decode(self._coding)
|
||||
except UnicodeEncodeError:
|
||||
pass
|
||||
|
||||
return super(CodingFormatter, self).format(format_string, *args,
|
||||
**kwargs)
|
||||
|
|
@ -96,10 +93,7 @@ class HookPlugin(BeetsPlugin):
|
|||
return
|
||||
|
||||
# Use a string formatter that works on Unicode strings.
|
||||
if six.PY2:
|
||||
formatter = CodingFormatter(arg_encoding())
|
||||
else:
|
||||
formatter = string.Formatter()
|
||||
formatter = CodingFormatter(arg_encoding())
|
||||
|
||||
command_pieces = shlex_split(command)
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,8 @@ Fixes:
|
|||
* :doc:`/plugins/badfiles`: Avoid a crash when the underlying tool emits
|
||||
undecodable output.
|
||||
:bug:`3165`
|
||||
* :doc:`/plugins/hook`: Fix byte string interpolation in hook commands.
|
||||
:bug:`2967` :bug:`3167`
|
||||
|
||||
.. _python-itunes: https://github.com/ocelma/python-itunes
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue