From fc3f64de95554a66e2ec64804acf9c6032dd7e7b Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 31 May 2016 17:52:32 -0700 Subject: [PATCH] Convert stub: Python 3 compatibility Important for systems where `python` is 3.x, like Arch, even when beets itself is running on Python 2. --- test/rsrc/convert_stub.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/rsrc/convert_stub.py b/test/rsrc/convert_stub.py index 0f2dadd92..aa0d2ea72 100755 --- a/test/rsrc/convert_stub.py +++ b/test/rsrc/convert_stub.py @@ -10,6 +10,10 @@ import sys def convert(in_file, out_file, tag): """Copy `in_file` to `out_file` and append the string `tag`. """ + # On Python 3, encode the tag argument as bytes. + if not isinstance(tag, bytes): + tag = tag.encode('utf8') + with open(out_file, 'wb') as out_f: with open(in_file, 'rb') as in_f: out_f.write(in_f.read())