Skip to content

input function outputs prompt to stderr #69878

Closed

Description

@jaraco
BPO 25692
Nosy @jaraco, @vadmium
Superseder
  • bpo-1927: Change input() to always prompt to stderr
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-11-21.23:09:28.737>
    created_at = <Date 2015-11-21.22:01:43.070>
    labels = []
    title = 'input function outputs prompt to stderr'
    updated_at = <Date 2015-11-21.23:09:28.735>
    user = 'https://github.com/jaraco'

    bugs.python.org fields:

    activity = <Date 2015-11-21.23:09:28.735>
    actor = 'martin.panter'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-11-21.23:09:28.737>
    closer = 'martin.panter'
    components = []
    creation = <Date 2015-11-21.22:01:43.070>
    creator = 'jaraco'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 25692
    keywords = []
    message_count = 2.0
    messages = ['255072', '255076']
    nosy_count = 2.0
    nosy_names = ['jaraco', 'martin.panter']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '1927'
    type = None
    url = 'https://bugs.python.org/issue25692'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4', 'Python 3.5', 'Python 3.6']

    Activity

    1. jaraco commented on Nov 21, 2015

      @jaraco
      MemberAuthor

      The built-in function 'input' appears to be sending the prompt to stderr instead of stdout, as the docs state it should.

      $ python3.5 -c "print('stdout'); import sys; print('stderr', file=sys.stderr); input('foo')" 2> errors.txt
      stdout
      hello
      $ cat errors.txt
      stderr
      foo

      I've replicated this behavior in both Python 3.4 on Linux and Python 3.5 and 2.7 on OS X. Here's the 2.7 test/output:

      $ python2.7 -c "from __future__ import print_function; print('stdout'); import sys; print('stderr', file=sys.stderr); raw_input('foo')" 2> errors.txt
      stdout
      hello
      $ cat errors.txt 
      stderr
      foo

      I believe the stated behavior (outputting the prompt to stdout) is the proper behavior.

      I figure I must be doing something wrong here, because it seems bizarre to me that this discrepancy hasn't been discovered before.

    2. vadmium commented on Nov 21, 2015

      @vadmium
      Member

      This has been discovered before: bpo-1927, with a simple patch. The choice between stdout and stderr seems to be rather complicated, so the patch may need a bit more work.

    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      No labels
      No labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions