diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index ba058148d..cd9f4989e 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -790,9 +790,6 @@ def _store_dict(option, opt_str, value, parser): setattr(parser.values, dest, {}) option_values = getattr(parser.values, dest) - # Decode the argument using the platform's argument encoding. - value = util.text_string(value, util.arg_encoding()) - try: key, value = value.split('=', 1) if not (key and value): diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 91cee4516..6c8e25b85 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1778,7 +1778,7 @@ def config_func(lib, opts, args): else: config_out = config.dump(full=opts.defaults, redact=opts.redact) if config_out.strip() != '{}': - print_(util.text_string(config_out)) + print_(config_out) else: print("Empty configuration") @@ -1852,7 +1852,7 @@ def completion_script(commands): """ base_script = os.path.join(os.path.dirname(__file__), 'completion_base.sh') with open(base_script) as base_script: - yield util.text_string(base_script.read()) + yield base_script.read() options = {} aliases = {} diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 07ef021ea..fbff07660 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -770,19 +770,6 @@ def as_string(value): return str(value) -def text_string(value, encoding='utf-8'): - """Convert a string, which can either be bytes or unicode, to - unicode. - - Text (unicode) is left untouched; bytes are decoded. This is useful - to convert from a "native string" (bytes on Python 2, str on Python - 3) to a consistently unicode value. - """ - if isinstance(value, bytes): - return value.decode(encoding) - return value - - def plurality(objs): """Given a sequence of hashble objects, returns the object that is most common in the set and the its number of appearance. The diff --git a/beetsplug/keyfinder.py b/beetsplug/keyfinder.py index 051af9e1f..412b7ddaa 100644 --- a/beetsplug/keyfinder.py +++ b/beetsplug/keyfinder.py @@ -77,7 +77,7 @@ class KeyFinderPlugin(BeetsPlugin): continue try: - key = util.text_string(key_raw) + key = key_raw.decode("utf-8") except UnicodeDecodeError: self._log.error('output is invalid UTF-8') continue diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 6a70a962d..7b04f3714 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -320,9 +320,9 @@ def item_file(item_id): try: # Imitate http.server behaviour - unicode_base_filename.encode("latin-1", "strict") + base_filename.encode("latin-1", "strict") except UnicodeError: - safe_filename = unidecode(unicode_base_filename) + safe_filename = unidecode(base_filename) else: safe_filename = unicode_base_filename diff --git a/test/helper.py b/test/helper.py index f7d37b654..b6e425c62 100644 --- a/test/helper.py +++ b/test/helper.py @@ -453,7 +453,7 @@ class TestHelper: def run_with_output(self, *args): with capture_stdout() as out: self.run_command(*args) - return util.text_string(out.getvalue()) + return out.getvalue() # Safe file operations diff --git a/test/test_ui.py b/test/test_ui.py index ad4387013..2034fb41f 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -1163,8 +1163,7 @@ class ShowChangeTest(_common.TestCase): cur_album, autotag.AlbumMatch(album_dist, info, mapping, set(), set()), ) - # FIXME decoding shouldn't be done here - return util.text_string(self.io.getoutput().lower()) + return self.io.getoutput().lower() def test_null_change(self): msg = self._show_change()