From c1b4a6bd6151d0f777c5256e1d5e2304717932e6 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 28 Feb 2025 16:24:05 +0200 Subject: gh-130665: Only apply locale to calendar CLI via `--locale` and not `LANG` env var (#130676) --- Lib/calendar.py | 10 ++++++++-- .../Library/2025-02-28-11-56-19.gh-issue-130665.cfksVk.rst | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-02-28-11-56-19.gh-issue-130665.cfksVk.rst diff --git a/Lib/calendar.py b/Lib/calendar.py index 1105a70..01a76ff 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 0000000..73ae101 --- /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. -- cgit v0.12