From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 28 Feb 2025 14:24:05 +0000 (+0200) Subject: gh-130665: Only apply locale to calendar CLI via `--locale` and not `LANG` env var... X-Git-Tag: v3.14.0a6~222 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c1b4a6bd6151d0f777c5256e1d5e2304717932e6;p=thirdparty%2FPython%2Fcpython.git gh-130665: Only apply locale to calendar CLI via `--locale` and not `LANG` env var (#130676) --- diff --git a/Lib/calendar.py b/Lib/calendar.py index 1105a705a803..01a76ff8e78c 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -648,7 +648,7 @@ class LocaleHTMLCalendar(HTMLCalendar): 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 @@ class _CLIDemoCalendar(LocaleTextCalendar): 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 000000000000..73ae101e6041 --- /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.