]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-111276: Clarify docs and comments about the role of LC_CTYPE (GH-111319...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 27 Oct 2023 15:15:06 +0000 (17:15 +0200)
committerGitHub <noreply@github.com>
Fri, 27 Oct 2023 15:15:06 +0000 (17:15 +0200)
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 6d42759c5e47ab62d60a72b4ff15d29864554579)

Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Doc/library/locale.rst
Lib/logging/handlers.py

index 0817ae5883ce8a6a53a41a0c5990ce06fa72c2ab..2a6d911d6b4ae3414e5322ce6b0714801d3381be 100644 (file)
@@ -464,11 +464,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
index 671cc9596b02dd4068eb5de1aade13d23593dbcc..6e88184b5123c4a5c1ee10d285327e6c41010d53 100644 (file)
@@ -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",