]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131146: Fall back to `month_name` if `standalone_month_name`s aren't distinct...
authorPetr Viktorin <encukou@gmail.com>
Wed, 13 Aug 2025 07:03:05 +0000 (09:03 +0200)
committerGitHub <noreply@github.com>
Wed, 13 Aug 2025 07:03:05 +0000 (07:03 +0000)
Some systems reportedly don't expand '%OB' and '%Ob'.
In this case (and similar theoretically possible ones, like expanding to empty
string or 'OB'), fall back to the month_name & month_abbr.

Lib/calendar.py

index 45bb265a65602c2f6ef6debfd521a940f9b0c609..fd6c561a9d39b8593cd9e9ff6255a260d67598c6 100644 (file)
@@ -149,6 +149,14 @@ try:
 except ValueError:
     standalone_month_name = month_name
     standalone_month_abbr = month_abbr
+else:
+    # Some systems that do not support '%OB' will keep it as-is (i.e.,
+    # we get [..., '%OB', '%OB', '%OB']), so for non-distinct names,
+    # we fall back to month_name/month_abbr.
+    if len(set(standalone_month_name)) != len(set(month_name)):
+        standalone_month_name = month_name
+    if len(set(standalone_month_abbr)) != len(set(month_abbr)):
+        standalone_month_abbr = month_abbr
 
 
 def isleap(year):