| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -160,11 +160,13 @@ def get_child_details(cls, env_vars): | |
| AVAILABLE_TARGETS = None | ||
| CLI_COERCION_TARGET = None | ||
| CLI_COERCION_WARNING = None | ||
| DEFAULT_LC_CTYPE = None | ||
|
|
||
| def setUpModule(): | ||
| global AVAILABLE_TARGETS | ||
| global CLI_COERCION_TARGET | ||
| global CLI_COERCION_WARNING | ||
| global DEFAULT_LC_CTYPE | ||
|
|
||
| if AVAILABLE_TARGETS is not None: | ||
| # initialization already done | ||
| Expand All | @@ -181,6 +183,22 @@ def setUpModule(): | |
| CLI_COERCION_TARGET = AVAILABLE_TARGETS[0] | ||
| CLI_COERCION_WARNING = CLI_COERCION_WARNING_FMT.format(CLI_COERCION_TARGET) | ||
|
|
||
| # Determine the platform's default LC_CTYPE from the default locale. | ||
| # POSIX provides that there *exists* a default locale to provide when | ||
| # no environment variables are set, or are set to empty strings. However, | ||
| # it does not specify that this default *must* be the "POSIX" locale, or | ||
| # how the platform selects the default. In most cases it will be set to | ||
| # "C"/"POSIX" but this is not necessarily the case. | ||
| result, py_cmd = run_python_until_end( | ||
| "-c", "import locale; print(locale.setlocale(locale.LC_CTYPE))", | ||
| __isolated=True, | ||
| LANG="", LC_ALL="", LC_CTYPE="", PYTHONCOERCECLOCALE="0" | ||
| ) | ||
| if not result.rc == 0: | ||
| result.fail(py_cmd) | ||
|
|
||
| DEFAULT_LC_CTYPE = result.out.decode("ascii").strip().upper() | ||
|
|
||
|
|
||
| class _LocaleHandlingTestCase(unittest.TestCase): | ||
| # Base class to check expected locale handling behaviour | ||
| Expand Down Expand Up | @@ -301,6 +319,11 @@ def _check_c_locale_coercion(self, | |
| # See https://bugs.python.org/issue30672 for discussion | ||
| if locale_to_set == "POSIX": | ||
| continue | ||
| elif locale_to_set == "" and DEFAULT_LC_CTYPE == "C.UTF-8": | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe condition is too restrictive:
Sorry, something went wrong.
All reactions
|
||
| # The default locale is already C.UTF-8 so the subsequent tests | ||
| # don't behave as expected (they assume the default LC_CTYPE will | ||
| # be "C") | ||
| continue | ||
| with self.subTest(env_var=env_var, | ||
| nominal_locale=locale_to_set, | ||
| PYTHONCOERCECLOCALE=coerce_c_locale): | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDid you try setting C_LOCALE_STREAM_ENCODING to "utf-8" instead ?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.