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
Provenance
- Commit
9b2648a- Tree
09a45da- Author
Kevin Yap <me@kevinyap.ca>- Committer
Kevin Yap <me@kevinyap.ca>- Parent
e4dca8a
8 files changed+23 added−23 removed
modified:click/core.py+1 added-1 removed
399 unmodified lines400 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 linesmodified:click/testing.py+1 added-1 removed
94 unmodified lines95 global interpreter state.96 97 :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 prompts165 unmodified linesmodified:click/utils.py+2 added-2 removed
227 unmodified lines228 # 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)231 232- # 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 linesmodified:docs/python3.rst+9 added-9 removed
22 unmodified lines23 some situations where this can break. The most common one is SSH24 connections to machines with different locales.25 26 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!29 30 For more information see :ref:`python3-surrogates`.31 32-* 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 lines57 58 Click attempts to minimize the differences between Python 2 and Python 359 by following the best practices for both languages.60 61-On Python 2, the following is true:61+in Python 2, the following is true:62 63 * ``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 streams5 unmodified lines71 * 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.74 75-On Python 3, the following is true:75+in Python 3, the following is true:76 77 * ``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 how14 unmodified lines94 95 Python 3 Surrogate Handling96 ---------------------------97 98-Click on Python 3 does all the Unicode handling in the standard library99-and is subject to its behavior. On Python 2, click does all the Unicode98+Click in Python 3 does all the Unicode handling in the standard library99+and is subject to its behavior. In Python 2, click does all the Unicode100 handling itself, which means there are differences in error behavior.101 102-The most glaring difference is that on Python 2, Unicode will "just work",103-while on Python 3, it requires extra care. The reason for this is that on102+The most glaring difference is that in Python 2, Unicode will "just work",103+while in Python 3, it requires extra care. The reason for this is that on104 Python 3, the encoding detection is done in the interpreter and on Linux105 and certain other operating systems its encoding handling is problematic.106 107 The biggest source of frustration is that click scripts invoked by5 unmodified lines113 to force you to set a locale. This is done because click cannot know114 about the state of the system once it's invoked and restore the values115 before Python's Unicode handling kicked in.116 117-If you see something like this error on Python 3::117+If you see something like this error in Python 3::118 119 Traceback (most recent call last):120 ...121 RuntimeError: Click will abort further execution because Python 3 was33 unmodified linesmodified:docs/utils.rst+6 added-6 removed
11 unmodified lines12 ------------------13 14 The most obvious helper is the :func:`echo` function, which in many ways15 works like the Python print statement or function. The main difference is16-that it works the same on Python 2 and 3, it intelligently detects17-misconfigured output streams, and will never fail (except on Python 3; for16+that it works the same in Python 2 and 3, it intelligently detects17+misconfigured output streams, and will never fail (except in Python 3; for18 more information see :ref:`python3-limitations`).19 20 Example::21 1 unmodified line23 24 click.echo('Hello World!')25 26 Most importantly, it can print both Unicode and binary data, unlike the27-builtin ``print`` function on Python 3, which cannot output any bytes. It27+builtin ``print`` function in Python 3, which cannot output any bytes. It28 will, however, emit a trailing newline by default which needs to be29 supressed by passing ``nl=False``::30 31 click.echo(b'\xe2\x98\x83', nl=False)188 unmodified lines220 Printing Filenames221 ------------------222 223 Because filenames might not be Unicode, formatting them can be a bit224-tricky. Generally, this is easier on Python 2 than on 3, as you can just225-write the bytes to stdout with the print function, but on Python 3, you will224+tricky. Generally, this is easier in Python 2 than on 3, as you can just225+write the bytes to stdout with the print function, but in Python 3, you will226 always need to operate in Unicode.227 228 The way this works with click is through the :func:`format_filename`229 function. It does a best-effort conversion of the filename to Unicode and18 unmodified lines248 :func:`get_text_stream` functions, which produce consistent results with249 different Python versions and for a wide variety pf terminal configurations.250 251 The end result is that these functions will always return a functional252-stream object (except in very odd cases on Python 3; see252+stream object (except in very odd cases in Python 3; see253 :ref:`python3-limitations`).254 255 Example::256 80 unmodified linesmodified:docs/why.rst+1 added-1 removed
10 unmodified lines11 * 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 linesmodified:tests/test_utils.py+2 added-2 removed
10 unmodified lines11 click.echo('\x1b[31mx\x1b[39m', nl=False)12 bytes = out.getvalue()13 assert bytes == b'\xe2\x98\x83\nDD\n42ax'14 15- # 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 linesmodified:CHANGES+1 added-1 removed
43 unmodified lines44 -----------45 46 (bugfix release, released on May 23rd 2014)47 48-- 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.50 51 Version 1.052 -----------4 unmodified lines