Skip to content

Commit 639df39

Browse files
authored
gh-131146: Fall back to month_name if standalone_month_names aren't distinct (GH-137674)
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.
1 parent 797c2c3 commit 639df39

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/calendar.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ def __len__(self):
149149
except ValueError:
150150
standalone_month_name = month_name
151151
standalone_month_abbr = month_abbr
152+
else:
153+
# Some systems that do not support '%OB' will keep it as-is (i.e.,
154+
# we get [..., '%OB', '%OB', '%OB']), so for non-distinct names,
155+
# we fall back to month_name/month_abbr.
156+
if len(set(standalone_month_name)) != len(set(month_name)):
157+
standalone_month_name = month_name
158+
if len(set(standalone_month_abbr)) != len(set(month_abbr)):
159+
standalone_month_abbr = month_abbr
152160

153161

154162
def isleap(year):

0 commit comments

Comments
 (0)