Skip to content
Myr

Abort with a clear error message on Python 3 if the env is ASCII.

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

authored by Armin Ronacher · committed by Armin Ronacher · parent dc2381a · Browse files · 1 file+19 added−0 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+19 added−0 removed

  • other:+19 added−0 removed

1 file+19 added−0 removed

modified:click/core.py+19 added
1import os2import sys3import codecs4from itertools import chain56from .types import convert_type, BOOL7from .utils import echo8from .exceptions import UsageError, Abort9from .helpers import prompt, confirm1011from . import _optparse12from ._compat import PY21314_missing = object()1516
276 unmodified lines
293 name from ``sys.argv[0]``.294 :param extra: extra keyword arguments are forwarded to the context295 constructor.296 """297 # If we are on python 3 we will verify that the environment is298 # sane at this point of reject further execution to avoid a299 # broken script.300 if not PY2:301 try:302 import locale303 fs_enc = codecs.lookup(locale.getpreferredencoding()).name304 except Exception:305 fs_enc = 'ascii'306 if fs_enc == 'ascii':307 raise RuntimeError('Click will abort further execution '308 'because Python 3 was configured to use '309 'ASCII as encoding for the environment. '310 'Either switch to Python 2 or consult '311 'http://bugs.python.org/issue13643 '312 'for mitigation steps.')313314 if args is None:315 args = sys.argv[1:]316 else:317 args = list(args)
555 unmodified lines