]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-130665: Only apply locale to calendar CLI via `--locale` and not `LANG` env var...
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Fri, 28 Feb 2025 14:24:05 +0000 (16:24 +0200)
committerGitHub <noreply@github.com>
Fri, 28 Feb 2025 14:24:05 +0000 (16:24 +0200)
Lib/calendar.py
Misc/NEWS.d/next/Library/2025-02-28-11-56-19.gh-issue-130665.cfksVk.rst [new file with mode: 0644]

index 1105a705a8036abe0098440d4bd3cb7355837b2b..01a76ff8e78c45ad7a64ddf254f1cac30558ab43 100644 (file)
@@ -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 (file)
index 0000000..73ae101
--- /dev/null
@@ -0,0 +1,2 @@
+Only apply locale to :ref:`calendar CLI <calendar-cli>` when set via
+``--locale`` and not via ``LANG`` environment variable.