Skip to content

Conversation

@jdufresne
Copy link
Contributor

Never used. Both Python 2.7 and Python 3 have the type bytes. On Python
2.7 it is an alias for str, same as what was previously defined.

Never used. Both Python 2.7 and Python 3 have the type bytes. On Python
2.7 it is an alias for str, same as what was previously defined.
@Julian
Copy link
Contributor

Julian commented Dec 31, 2018

Not a click author, but seems to me that it's unlikely that the point of that line was to be "useful", otherwise the next line (raw_input = raw_input) is even more transparently pointless.

I suspect instead that the point is to explicitly list each cross-compatible name that is to be made available.

@jdufresne
Copy link
Contributor Author

jdufresne commented Dec 31, 2018

The next line raw_input = raw_input is required as Python 2 & 3 have differences in input handling. See:

https://docs.python.org/3/whatsnew/3.0.html#builtins

PEP 3111: raw_input() was renamed to input(). That is, the new input() function reads a line from sys.stdin and returns it with the trailing newline stripped. It raises EOFError if the input is terminated

The raw_input needs to be always be importable from _compat.py to make this transparent to uses in click.

This is not true of bytes. Both Python 2 & 3 have the type bytes. So there is no need to define it explicitly as a compatability shim. Observe:

$ python2
>>> bytes
<type 'str'>

bytes is never imported from _compat.py.

Therefore, I still believe this is a cleanup of unused code.

@davidism davidism merged commit 6cf69b7 into pallets:master Dec 31, 2018
@davidism davidism added this to the 8.0 milestone Dec 31, 2018
@jdufresne jdufresne deleted the bytes branch December 31, 2018 16:30
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants