summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2022-02-18 14:12:38 -0800
committerDavid Lord <davidism@gmail.com>2022-02-18 14:12:38 -0800
commit0ccada0e64dbb42eecea8386b5e4e41146b9b0f6 (patch)
tree495f98f9d4a3dcc889fa9fb111234ac15fe227ff /src
parente7cff2a3dcb40df267e8cf92b80396a4875dece8 (diff)
downloadclick-0ccada0e64dbb42eecea8386b5e4e41146b9b0f6.tar.gz
remove utf-8 detection
Diffstat (limited to 'src')
-rw-r--r--src/click/_unicodefun.py100
-rw-r--r--src/click/core.py5
2 files changed, 0 insertions, 105 deletions
diff --git a/src/click/_unicodefun.py b/src/click/_unicodefun.py
deleted file mode 100644
index 9cb30c3..0000000
--- a/src/click/_unicodefun.py
+++ /dev/null
@@ -1,100 +0,0 @@
-import codecs
-import os
-from gettext import gettext as _
-
-
-def _verify_python_env() -> None:
- """Ensures that the environment is good for Unicode."""
- try:
- from locale import getpreferredencoding
-
- fs_enc = codecs.lookup(getpreferredencoding()).name
- except Exception:
- fs_enc = "ascii"
-
- if fs_enc != "ascii":
- return
-
- extra = [
- _(
- "Click will abort further execution because Python was"
- " configured to use ASCII as encoding for the environment."
- " Consult https://click.palletsprojects.com/unicode-support/"
- " for mitigation steps."
- )
- ]
-
- if os.name == "posix":
- import subprocess
-
- try:
- rv = subprocess.Popen(
- ["locale", "-a"],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="ascii",
- errors="replace",
- ).communicate()[0]
- except OSError:
- rv = ""
-
- good_locales = set()
- has_c_utf8 = False
-
- for line in rv.splitlines():
- locale = line.strip()
-
- if locale.lower().endswith((".utf-8", ".utf8")):
- good_locales.add(locale)
-
- if locale.lower() in ("c.utf8", "c.utf-8"):
- has_c_utf8 = True
-
- if not good_locales:
- extra.append(
- _(
- "Additional information: on this system no suitable"
- " UTF-8 locales were discovered. This most likely"
- " requires resolving by reconfiguring the locale"
- " system."
- )
- )
- elif has_c_utf8:
- extra.append(
- _(
- "This system supports the C.UTF-8 locale which is"
- " recommended. You might be able to resolve your"
- " issue by exporting the following environment"
- " variables:"
- )
- )
- extra.append(" export LC_ALL=C.UTF-8\n export LANG=C.UTF-8")
- else:
- extra.append(
- _(
- "This system lists some UTF-8 supporting locales"
- " that you can pick from. The following suitable"
- " locales were discovered: {locales}"
- ).format(locales=", ".join(sorted(good_locales)))
- )
-
- bad_locale = None
-
- for env_locale in os.environ.get("LC_ALL"), os.environ.get("LANG"):
- if env_locale and env_locale.lower().endswith((".utf-8", ".utf8")):
- bad_locale = env_locale
-
- if env_locale is not None:
- break
-
- if bad_locale is not None:
- extra.append(
- _(
- "Click discovered that you exported a UTF-8 locale"
- " but the locale system could not pick up from it"
- " because it does not exist. The exported locale is"
- " {locale!r} but it is not supported."
- ).format(locale=bad_locale)
- )
-
- raise RuntimeError("\n\n".join(extra))
diff --git a/src/click/core.py b/src/click/core.py
index a89dab2..95d852b 100644
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -14,7 +14,6 @@ from gettext import ngettext
from itertools import repeat
from . import types
-from ._unicodefun import _verify_python_env
from .exceptions import Abort
from .exceptions import BadParameter
from .exceptions import ClickException
@@ -1029,10 +1028,6 @@ class BaseCommand:
.. versionchanged:: 3.0
Added the ``standalone_mode`` parameter.
"""
- # Verify that the environment is configured correctly, or reject
- # further execution to avoid a broken script.
- _verify_python_env()
-
if args is None:
args = sys.argv[1:]