Repository navigation
Fix click.getchar return type - #1473
Conversation
|
Are you sure? http://click.pocoo.org/5/utils/#getting-characters-from-terminal says getchar returns a character as "a Unicode character". The implementation at https://github.com/pallets/click/blob/master/click/_termui_impl.py#L518 suggests it may return bytes in Python 3 on Windows, but in all other circumstances it decodes the character first. |
|
Hmm I was on Windows and python 3 and saw a So yeah, you're right it's not correct. But... I don't think it's the greatest API to return a |
|
I think you can do this with version/platform checks (unless I'm misreading the code): the return type is bytes if you're on Windows and Python 3, and otherwise Text. I have a hard time understanding why it's implemented this way though; maybe it's a bug in the library? |
|
Ok, let me ask on |
|
Your click issue didn't get much response, but the one responder also seems to think that returning bytes on Windows in Python 3 is unexpected. For now, can we just change the return annotation to |
|
Ping? Is this still needed? It's been well over half a year since the last activity. |
|
I just implemented my suggestion above of using |
The docs and actual behavior confirm
click.getcharreturns abytesobject.