From 096973fe92bc29648d1c6a5296cbc0a0f672bb7a Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 12 Aug 2025 15:45:35 +0200 Subject: [PATCH 1/2] gh-131146: Fall back to `month_name` if `standalone_month_name`s aren't distinct 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/calendar.py b/Lib/calendar.py index 45bb265a65602c..e00448f7c93590 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -149,6 +149,14 @@ def __len__(self): 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 if 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): From 597111e840d143258ef681447b32c42e0f596caf Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 13 Aug 2025 08:36:23 +0200 Subject: [PATCH 2/2] Typo --- Lib/calendar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/calendar.py b/Lib/calendar.py index e00448f7c93590..fd6c561a9d39b8 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -151,7 +151,7 @@ def __len__(self): 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 if for non-distinct names, + # 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