mirror of
https://github.com/beetbox/beets.git
synced 2026-02-24 16:23:04 +01:00
encode args before decode in convert_stub.py for py 3
We encode the args from `sys.argv` with `util.arg_encoding` to make sure we have paths that cleanly open when running `convert_stub.py` on Windows
This commit is contained in:
parent
fb78830788
commit
bcc77f747b
1 changed files with 12 additions and 2 deletions
|
|
@ -6,9 +6,16 @@ a specified text tag.
|
|||
"""
|
||||
|
||||
from __future__ import division, absolute_import, print_function
|
||||
from os.path import dirname, abspath
|
||||
import six
|
||||
import sys
|
||||
import platform
|
||||
|
||||
beets_src = dirname(dirname(dirname(abspath(__file__))))
|
||||
sys.path.insert(0, beets_src)
|
||||
|
||||
from beets.util import arg_encoding # noqa: E402
|
||||
|
||||
|
||||
def convert(in_file, out_file, tag):
|
||||
"""Copy `in_file` to `out_file` and append the string `tag`.
|
||||
|
|
@ -20,8 +27,11 @@ def convert(in_file, out_file, tag):
|
|||
# On Windows, use Unicode paths. (The test harness gives them to us
|
||||
# as UTF-8 bytes.)
|
||||
if platform.system() == 'Windows':
|
||||
in_file = in_file.decode('utf8')
|
||||
out_file = out_file.decode('utf8')
|
||||
if not six.PY2:
|
||||
in_file = in_file.encode(arg_encoding())
|
||||
out_file = out_file.encode(arg_encoding())
|
||||
in_file = in_file.decode('utf-8')
|
||||
out_file = out_file.decode('utf-8')
|
||||
|
||||
with open(out_file, 'wb') as out_f:
|
||||
with open(in_file, 'rb') as in_f:
|
||||
|
|
|
|||
Loading…
Reference in a new issue