Skip to content

Commit 6d42759

Browse files
ambvhugovk
andauthored
gh-111276: Clarify docs and comments about the role of LC_CTYPE (#111319)
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.html#deprecated-string-functions Also, fix a comment in logging about locale-specific behavior of `str.lower()`. Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 74f0772 commit 6d42759

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
@@ -454,11 +454,16 @@ The :mod:`locale` module defines the following exception and functions:
454454

455455
.. data:: LC_CTYPE
456456

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

463468

464469
.. data:: LC_COLLATE

Lib/logging/handlers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -830,10 +830,8 @@ class SysLogHandler(logging.Handler):
830830
"local7": LOG_LOCAL7,
831831
}
832832

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

0 commit comments

Comments
 (0)