Skip to content

Inconsistent return type from click.getchar() #822

Closed

Description

@pkch

It seems that click.getchar() will return bytes under python 3 / Windows, and str under any other combination of python version and platform. Is this the intended behavior or a bug?

I wanted to update the stub for click but if it's a bug and can be fixed soon, I can leave the typeshed stub unchanged.

Activity

  1. ScottSturdivant commented on Sep 7, 2017

    @ScottSturdivant

    The documentation states:

    This will always return a unicode character

    I've witnessed the same behavior (bytes w/Python3 and Windows, str elsewhere) and to me, this inconsistency is a bug.

  2. ScottSturdivant commented on Sep 7, 2017

    @ScottSturdivant

    Can anyone see a reason for this PY2 guard here?

  3. kip-13 commented on Mar 18, 2018

    @kip-13

    The python 3 doc's is clear with this:

    Read a keypress and return the resulting character as a byte string

    In python 2 doc say this:

    Read a keypress and return the resulting character

  4. JelleZijlstra commented on Mar 18, 2018

    @JelleZijlstra

    Those are docs for the standard library, not for click.

  5. kip-13 commented on Mar 18, 2018

    @kip-13

    @JelleZijlstra I know, but if you see the code of getchar you understand why I mentioned the module msvcrt (Windows / Python 3.x use case)

  6. sirosen commented on Sep 18, 2018

    @sirosen
    Contributor

    Closed by #1108

  7. added this to the 7.0 milestone on Sep 18, 2018
  8. added 2 commits that reference this issue on Oct 8, 2018
  9. added a commit that references this issue on Oct 29, 2018
  10. locked as resolved and limited conversation to collaborators on Nov 13, 2020
  11. added
    typing
    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

    typing

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions