Skip to content
Myr

Merge pull request #247 from homeworkprod/patch-1

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

A few documentation fixes.

authored by Armin Ronacher · committed by Armin Ronacher · parents 7c138a6, 3c2de84 · Browse files · 1 file+9 added−9 removed
This commit

State

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

Diff stats

1 file+9 added−9 removed

  • other:+9 added−9 removed

1 file+9 added−9 removed

modified:docs/python3.rst+9 added-9 removed
16 unmodified lines
17--------------------1819At the moment, Click suffers from a few problems with Python 3:2021* The command line in Unix traditionally is in bytes, and not Unicode.22 While there are encoding hints for all of this, there are generally23 some situations where this can break. The most common one is SSH21* The command line in Unix traditionally is in bytes, not Unicode. While22 there are encoding hints for all of this, there are generally some23 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 in Python 3 due to the lack of support for roundtripping
27 unmodified lines
55Python 2 and 3 Differences56--------------------------5758Click attempts to minimize the differences between Python 2 and Python 359by following the best practices for both languages.59by following best practices for both languages.6061In Python 2, the following is true:6263* ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` are opened in binary
16 unmodified lines
80 this works.81* ``sys.argv`` is always Unicode-based. This also means that the native82 type for input values to the types in Click is Unicode, and not bytes.8384 This causes problems when the terminal is incorrectly set and Python84 This causes problems if the terminal is incorrectly set and Python85 does not figure out the encoding. In that case, the Unicode string86 will contain error bytes encoded as surrogate escapes.87* When dealing with files, Click will always use the Unicode file system88 API calls by using the operating system's reported or guessed
10 unmodified lines
99and 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 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.103while in Python 3, it requires extra care. The reason for this is that in104Python 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 by108init systems (sysvinit, upstart, systemd, etc.), deployment tools (salt,109puppet), or cron jobs (cron) will refuse to work unless a Unicode locale is
9 unmodified lines
119 Traceback (most recent call last):120 ...121 RuntimeError: Click will abort further execution because Python 3 was122 configured to use ASCII as encoding for the environment. Either switch123 to Python 2 or consult for http://click.pocoo.org/python3/123 to Python 2 or consult http://click.pocoo.org/python3/ for124 mitigation steps.125126You are dealing with an environment where Python 3 thinks you are127restricted to ASCII data. The solution to these problems is different
27 unmodified lines