diff --git a/Lib/calendar.py b/Lib/calendar.py index 1105a705a8036a..01a76ff8e78c45 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -648,7 +648,7 @@ def formatmonthname(self, theyear, themonth, withyear=True): return super().formatmonthname(theyear, themonth, withyear) -class _CLIDemoCalendar(LocaleTextCalendar): +class _CLIDemoCalendar(TextCalendar): def __init__(self, highlight_day=None, *args, **kwargs): super().__init__(*args, **kwargs) self.highlight_day = highlight_day @@ -752,6 +752,12 @@ def formatyear(self, theyear, w=2, l=1, c=6, m=3): return ''.join(v) +class _CLIDemoLocaleCalendar(LocaleTextCalendar, _CLIDemoCalendar): + def __init__(self, highlight_day=None, *args, **kwargs): + super().__init__(*args, **kwargs) + self.highlight_day = highlight_day + + # Support for old module level interface c = TextCalendar() @@ -893,7 +899,7 @@ def main(args=None): write(cal.formatyearpage(options.year, **optdict)) else: if options.locale: - cal = _CLIDemoCalendar(highlight_day=today, locale=locale) + cal = _CLIDemoLocaleCalendar(highlight_day=today, locale=locale) else: cal = _CLIDemoCalendar(highlight_day=today) cal.setfirstweekday(options.first_weekday) diff --git a/Misc/NEWS.d/next/Library/2025-02-28-11-56-19.gh-issue-130665.cfksVk.rst b/Misc/NEWS.d/next/Library/2025-02-28-11-56-19.gh-issue-130665.cfksVk.rst new file mode 100644 index 00000000000000..73ae101e604165 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-02-28-11-56-19.gh-issue-130665.cfksVk.rst @@ -0,0 +1,2 @@ +Only apply locale to :ref:`calendar CLI ` when set via +``--locale`` and not via ``LANG`` environment variable.