8000 [3.11] gh-111276: Clarify docs and comments about the role of LC_CTYP… · python/cpython@a9e0455 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9e0455

Browse files
miss-islingtonambvhugovk
authored
[3.11] gh-111276: Clarify docs and comments about the role of LC_CTYPE (GH-111319) (#111392)
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 <lukasz@langa.pl> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
1 parent e7cdccc commit a9e0455

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Doc/library/locale.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,16 @@ The :mod:`locale` module defines the following exception and functions:
476476

477477
.. data:: LC_CTYPE
478478

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

485490

486491
.. data:: LC_COLLATE

Lib/logging/handlers.py

Lines changed: 2 additions & 4 deletions
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)
0