https://github.com/python/cpython/commit/c1b4a6bd6151d0f777c5256e1d5e2304717932e6 commit: c1b4a6bd6151d0f777c5256e1d5e2304717932e6 branch: main author: Hugo van Kemenade <1324225+hug...@users.noreply.github.com> committer: hugovk <1324225+hug...@users.noreply.github.com> date: 2025-02-28T16:24:05+02:00 summary:
gh-130665: Only apply locale to calendar CLI via `--locale` and not `LANG` env var (#130676) files: A Misc/NEWS.d/next/Library/2025-02-28-11-56-19.gh-issue-130665.cfksVk.rst M Lib/calendar.py 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 <calendar-cli>` when set via +``--locale`` and not via ``LANG`` environment variable. _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com