From b3e072467679270cc0bc66be9f65899b8ebc4fca Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 20 May 2012 11:42:53 -0700 Subject: [PATCH] send prompts to stdout (GC-389) --- beets/ui/__init__.py | 18 ++++++++---------- docs/changelog.rst | 1 + docs/reference/pathformat.rst | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 2059ce5b9..f3431c181 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -1,5 +1,5 @@ # This file is part of beets. -# Copyright 2011, Adrian Sampson. +# Copyright 2012, Adrian Sampson. # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -241,14 +241,11 @@ def input_options(options, require=False, prompt=None, fallback_prompt=None, fallback_prompt += '%i-%i, ' % numrange fallback_prompt += ', '.join(display_letters) + ':' - # Note: In the past, this line was causing problems with colors in - # the prompt string. However, using a separate "print prompt," line - # breaks the readline module, which expects the length of the prompt - # to be available to it. (Namely, entering text and then deleting it - # caused the entire last line of the prompt to disappear.) However, - # readline also seems to have fixed the issue with colors, so we've - # now switched back. - resp = raw_input(prompt + ' ') + # raw_input incorrectly sends prompts to stderr, not stdout, so we + # use print() explicitly to display prompts. + # http://bugs.python.org/issue1927 + print(prompt, end=' ') + resp = raw_input() while True: resp = resp.strip().lower() @@ -276,7 +273,8 @@ def input_options(options, require=False, prompt=None, fallback_prompt=None, return resp # Prompt for new input. - resp = raw_input(fallback_prompt + ' ') + print(fallback_prompt, end=' ') + resp = raw_input() def input_yn(prompt, require=False, color=False): """Prompts the user for a "yes" or "no" response. The default is diff --git a/docs/changelog.rst b/docs/changelog.rst index e1a61c6b4..8bddf436b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -34,6 +34,7 @@ Changelog * Fix ID3 tag name for the catalog number field. * :doc:`/plugins/chroma`: Fix occasional crash at end of fingerprint submission and give more context to "failed fingerprint generation" errors. +* Interactive prompts are sent to stdout instead of stderr. .. _artist credits: http://wiki.musicbrainz.org/Artist_Credit diff --git a/docs/reference/pathformat.rst b/docs/reference/pathformat.rst index 5c946e9ba..2cb469017 100644 --- a/docs/reference/pathformat.rst +++ b/docs/reference/pathformat.rst @@ -95,7 +95,7 @@ will expand to "[2008]" for one album and "[2010]" for the other. The function detects that you have two albums with the same artist and title but that they have different release years. -For full flexibility, the ``%auniqe`` function takes two arguments, each of +For full flexibility, the ``%aunique`` function takes two arguments, each of which are whitespace-separated lists of album field names: a set of *identifiers* and a set of *disambiguators*. Any group of albums with identical values for all the identifiers will be considered "duplicates". Then, the