From b81ac1d6e05ef73a3613134ea799332990706bc3 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 15 Oct 2012 14:58:59 -0700 Subject: [PATCH] fix crash when stdin comes from pipe w/o encoding This allows, for example, "yes | beet convert". --- beets/ui/__init__.py | 2 +- docs/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index d6a29a2e1..c3fb162e3 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -132,7 +132,7 @@ def input_(prompt=None): except EOFError: raise UserError('stdin stream ended while input required') - return resp.decode(sys.stdin.encoding, 'ignore') + return resp.decode(sys.stdin.encoding or 'utf8', 'ignore') def input_options(options, require=False, prompt=None, fallback_prompt=None, numrange=None, default=None, color=False, max_width=72): diff --git a/docs/changelog.rst b/docs/changelog.rst index 68922815e..19d95b86d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -56,6 +56,7 @@ Changelog non-ASCII extensions. * Fix for changing date fields (like "year") with the :ref:`modify-cmd` command. +* Fix a crash when input is read from a pipe without a specified encoding. * Add a human-readable error message when writing files' tags fails. * Changed plugin loading so that modules can be imported without unintentionally loading the plugins they contain.