Skip to content

Characters getting from terminal using getchar returns bytes #1088

Closed

Description

@lewoudar

Hello,
it is said in the documentation that getchar function always returns unicode there, but when i tried to use the code snippet of the documentation on my windows 10 machine, i always fell on "invalid input :("

I inspected the type of value returned and I realized that it was bytes. So either you have to change the documentation and the code like this:

    click.echo('Continue? [yn] ', nl=False)
    c = click.getchar()
    if c == b'y':
        click.echo('We will go on')
    elif c == b'n':
        click.echo('Abort!')
    else:
        click.echo('Invalid input :(')

either the problem have to be solved..

I'm using click 6.7, python 3.6 and I'm working under windows 10.

Activity

  1. added this to the 7.0 milestone on Sep 18, 2018
  2. added 2 commits that reference this issue on Oct 8, 2018
  3. added a commit that references this issue on Oct 29, 2018
  4. locked as resolved and limited conversation to collaborators on Nov 13, 2020
  5. added
    windows
    on Aug 8, 2026
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

    windows

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions