Skip to content
New issue

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

[3.11] gh-111276: Clarify docs and comments about the role of LC_CTYPE (GH-111319) #111392

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Doc/library/locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,16 @@ The :mod:`locale` module defines the following exception and functions:

.. data:: LC_CTYPE

.. index:: pair: module; string

Locale category for the character type functions. Depending on the settings of
this category, the functions of module :mod:`string` dealing with case change
their behaviour.
Locale category for the character type functions. Most importantly, this
category defines the text encoding, i.e. how bytes are interpreted as
Unicode codepoints. See :pep:`538` and :pep:`540` for how this variable
might be automatically coerced to ``C.UTF-8`` to avoid issues created by
invalid settings in containers or incompatible settings passed over remote
SSH connections.

Python doesn't internally use locale-dependent character transformation functions
from ``ctype.h``. Instead, an internal ``pyctype.h`` provides locale-independent
equivalents like :c:macro:`!Py_TOLOWER`.


.. data:: LC_COLLATE
Expand Down
6 changes: 2 additions & 4 deletions Lib/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,10 +833,8 @@ class SysLogHandler(logging.Handler):
"local7": LOG_LOCAL7,
}

#The map below appears to be trivially lowercasing the key. However,
#there's more to it than meets the eye - in some locales, lowercasing
#gives unexpected results. See SF #1524081: in the Turkish locale,
#"INFO".lower() != "info"
# Originally added to work around GH-43683. Unnecessary since GH-50043 but kept
# for backwards compatibility.
priority_map = {
"DEBUG" : "debug",
"INFO" : "info",
Expand Down