Skip to content
Myr

Changed occurrences of "on Python" to "in Python"

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kevin Yap · committed by Kevin Yap · parent e4dca8a · Browse files · 8 files+23 added−23 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+23 added−23 removed

  • tests:+2 added−2 removed
  • other:+21 added−21 removed

8 files+23 added−23 removed

modified:click/core.py+1 added-1 removed
399 unmodified lines
400 uppercase.401 :param extra: extra keyword arguments are forwarded to the context402 constructor. See :class:`Context` for more information.403 """404 # If we are on python 3 we will verify that the environment is404 # If we are in Python 3, we will verify that the environment is405 # sane at this point of reject further execution to avoid a406 # broken script.407 if not PY2:408 try:
855 unmodified lines
modified:click/testing.py+1 added-1 removed
94 unmodified lines
95 global interpreter state.9697 :param charset: the character set for the input and output data. This is98 utf-8 by default and should not be changed currently as99 the reporting to click only works on Python 2 properly.99 the reporting to click only works in Python 2 properly.100 :param env: a dictionary with environment variables for overriding.101 :param echo_stdin: if this is set to `True`, then reading from stdin writes102 to stdout. This is useful for showing examples in103 some circumstances. Note that regular prompts
165 unmodified lines
modified:click/utils.py+2 added-2 removed
227 unmodified lines
228 # Convert non bytes/text into the native string type.229 if message is not None and not isinstance(message, echo_native_types):230 message = text_type(message)231232 # If there is a message, and we're on python 3, and the value looks233 # like bytes we manually need to find the binary stream and write the232 # If there is a message, and we're in Python 3, and the value looks233 # like bytes, we manually need to find the binary stream and write the234 # message in there. This is done separately so that most stream235 # types will work as you would expect. Eg: you can write to StringIO236 # for other cases.237 if message and not PY2 and is_bytes(message):
125 unmodified lines
modified:docs/python3.rst+9 added-9 removed
22 unmodified lines
23 some situations where this can break. The most common one is SSH24 connections to machines with different locales.2526 Misconfigured environments can currently cause a wide range of Unicode27 problems on Python 3 due to the lack of support for roundtripping27 problems in Python 3 due to the lack of support for roundtripping28 surrogate escapes. This will not be fixed in click itself!2930 For more information see :ref:`python3-surrogates`.3132* Standard input and output on Python 3 is opened in Unicode mode by32* Standard input and output in Python 3 is opened in Unicode mode by33 default. Click has to reopen the stream in binary mode in certain34 situations. Because there is no standardized way to do this, this35 might not always work. Primarily this can become a problem when36 testing command-line applications.
20 unmodified lines
5758Click attempts to minimize the differences between Python 2 and Python 359by following the best practices for both languages.6061On Python 2, the following is true:61in Python 2, the following is true:6263* ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` are opened in binary64 mode, but under some circumstances they support Unicode output. Click65 attempts to not subvert this but provides support for forcing streams
5 unmodified lines
71* When dealing with files, click will never go through the Unicode APIs72 and will instead use the operating system's byte APIs to open the73 files.7475On Python 3, the following is true:75in Python 3, the following is true:7677* ``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` are by default78 text-based. When click needs a binary stream, it attempts to discover79 the underlying binary stream. See :ref:`python3-limitations` for how
14 unmodified lines
9495Python 3 Surrogate Handling96---------------------------9798Click on Python 3 does all the Unicode handling in the standard library99and is subject to its behavior. On Python 2, click does all the Unicode98Click in Python 3 does all the Unicode handling in the standard library99and is subject to its behavior. In Python 2, click does all the Unicode100handling itself, which means there are differences in error behavior.101102The most glaring difference is that on Python 2, Unicode will "just work",103while on Python 3, it requires extra care. The reason for this is that on102The most glaring difference is that in Python 2, Unicode will "just work",103while in Python 3, it requires extra care. The reason for this is that on104Python 3, the encoding detection is done in the interpreter and on Linux105and certain other operating systems its encoding handling is problematic.106107The biggest source of frustration is that click scripts invoked by
5 unmodified lines
113to force you to set a locale. This is done because click cannot know114about the state of the system once it's invoked and restore the values115before Python's Unicode handling kicked in.116117If you see something like this error on Python 3::117If you see something like this error in Python 3::118119 Traceback (most recent call last):120 ...121 RuntimeError: Click will abort further execution because Python 3 was
33 unmodified lines
modified:docs/utils.rst+6 added-6 removed
11 unmodified lines
12------------------1314The most obvious helper is the :func:`echo` function, which in many ways15works like the Python print statement or function. The main difference is16that it works the same on Python 2 and 3, it intelligently detects17misconfigured output streams, and will never fail (except on Python 3; for16that it works the same in Python 2 and 3, it intelligently detects17misconfigured output streams, and will never fail (except in Python 3; for18more information see :ref:`python3-limitations`).1920Example::21
1 unmodified line
2324 click.echo('Hello World!')2526Most importantly, it can print both Unicode and binary data, unlike the27builtin ``print`` function on Python 3, which cannot output any bytes. It27builtin ``print`` function in Python 3, which cannot output any bytes. It28will, however, emit a trailing newline by default which needs to be29supressed by passing ``nl=False``::3031 click.echo(b'\xe2\x98\x83', nl=False)
188 unmodified lines
220Printing Filenames221------------------222223Because filenames might not be Unicode, formatting them can be a bit224tricky. Generally, this is easier on Python 2 than on 3, as you can just225write the bytes to stdout with the print function, but on Python 3, you will224tricky. Generally, this is easier in Python 2 than on 3, as you can just225write the bytes to stdout with the print function, but in Python 3, you will226always need to operate in Unicode.227228The way this works with click is through the :func:`format_filename`229function. It does a best-effort conversion of the filename to Unicode and
18 unmodified lines
248:func:`get_text_stream` functions, which produce consistent results with249different Python versions and for a wide variety pf terminal configurations.250251The end result is that these functions will always return a functional252stream object (except in very odd cases on Python 3; see252stream object (except in very odd cases in Python 3; see253:ref:`python3-limitations`).254255Example::256
80 unmodified lines
modified:docs/why.rst+1 added-1 removed
10 unmodified lines
11* fully follows the UNIX command line conventions12* supports loading values from environment variables out of the box13* supports for prompting of custom values14* is fully nestable and composable15* works the same on Python 2 and 315* works the same in Python 2 and 316* supports file handling out of the box17* comes with useful common helpers (getting terminal dimensions,18 ANSI colors, fetching direct keyboard input, screen clearing,19 finding config paths, launching apps and editors, etc.)
133 unmodified lines
modified:tests/test_utils.py+2 added-2 removed
10 unmodified lines
11 click.echo('\x1b[31mx\x1b[39m', nl=False)12 bytes = out.getvalue()13 assert bytes == b'\xe2\x98\x83\nDD\n42ax'1415 # If we are on python 2 we expect that writing bytes into a string io16 # does not do anything crazy. On Python 315 # If we are in Python 2, we expect that writing bytes into a string io16 # does not do anything crazy. In Python 317 if sys.version_info[0] == 2:18 import StringIO19 sys.stdout = x = StringIO.StringIO()20 try:
93 unmodified lines
modified:CHANGES+1 added-1 removed
43 unmodified lines
44-----------4546(bugfix release, released on May 23rd 2014)4748- fixed a bug that caused text files on Python 2 to not accept48- fixed a bug that caused text files in Python 2 to not accept49 native strings.5051Version 1.052-----------
4 unmodified lines