Skip to content

Commit c1b4a6b

Browse files
authored
gh-130665: Only apply locale to calendar CLI via --locale and not LANG env var (#130676)
1 parent e21863c commit c1b4a6b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Lib/calendar.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ def formatmonthname(self, theyear, themonth, withyear=True):
648648
return super().formatmonthname(theyear, themonth, withyear)
649649

650650

651-
class _CLIDemoCalendar(LocaleTextCalendar):
651+
class _CLIDemoCalendar(TextCalendar):
652652
def __init__(self, highlight_day=None, *args, **kwargs):
653653
super().__init__(*args, **kwargs)
654654
self.highlight_day = highlight_day
@@ -752,6 +752,12 @@ def formatyear(self, theyear, w=2, l=1, c=6, m=3):
752752
return ''.join(v)
753753

754754

755+
class _CLIDemoLocaleCalendar(LocaleTextCalendar, _CLIDemoCalendar):
756+
def __init__(self, highlight_day=None, *args, **kwargs):
757+
super().__init__(*args, **kwargs)
758+
self.highlight_day = highlight_day
759+
760+
755761
# Support for old module level interface
756762
c = TextCalendar()
757763

@@ -893,7 +899,7 @@ def main(args=None):
893899
write(cal.formatyearpage(options.year, **optdict))
894900
else:
895901
if options.locale:
896-
cal = _CLIDemoCalendar(highlight_day=today, locale=locale)
902+
cal = _CLIDemoLocaleCalendar(highlight_day=today, locale=locale)
897903
else:
898904
cal = _CLIDemoCalendar(highlight_day=today)
899905
cal.setfirstweekday(options.first_weekday)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Only apply locale to :ref:`calendar CLI <calendar-cli>` when set via
2+
``--locale`` and not via ``LANG`` environment variable.

0 commit comments

Comments
 (0)