Skip to content

Commit 7132109

Browse files
miss-islingtonambvhugovk
authored
[3.12] gh-111276: Clarify docs and comments about the role of LC_CTYPE (GH-111319) (#111391)
Fix locale.LC_CTYPE documentation to no longer mention string.lower() et al. Those functions were removed in Python 3.0: https://docs.python.org/2/library/string.htmlGH-deprecated-string-functions Also, fix a comment in logging about locale-specific behavior of `str.lower()`. (cherry picked from commit 6d42759) Co-authored-by: Łukasz Langa <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 883233d commit 7132109

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Doc/library/locale.rst

+10-5
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,16 @@ The :mod:`locale` module defines the following exception and functions:
464464

465465
.. data:: LC_CTYPE
466466

467-
.. index:: pair: module; string
468-
469-
Locale category for the character type functions. Depending on the settings of
470-
this category, the functions of module :mod:`string` dealing with case change
471-
their behaviour.
467+
Locale category for the character type functions. Most importantly, this
468+
category defines the text encoding, i.e. how bytes are interpreted as
469+
Unicode codepoints. See :pep:`538` and :pep:`540` for how this variable
470+
might be automatically coerced to ``C.UTF-8`` to avoid issues created by
471+
invalid settings in containers or incompatible settings passed over remote
472+
SSH connections.
473+
474+
Python doesn't internally use locale-dependent character transformation functions
475+
from ``ctype.h``. Instead, an internal ``pyctype.h`` provides locale-independent
476+
equivalents like :c:macro:`!Py_TOLOWER`.
472477

473478

474479
.. data:: LC_COLLATE

Lib/logging/handlers.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,8 @@ class SysLogHandler(logging.Handler):
833833
"local7": LOG_LOCAL7,
834834
}
835835

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

0 commit comments

Comments
 (0)