Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ea1e60e
mark version to 3.14
youknowone Jan 13, 2026
7594ef5
upgrade site to 3.14.2
youknowone Jan 13, 2026
280caea
upgrade venvlauncher
youknowone Jan 13, 2026
8d901a7
Implement bool(NotImplemented)
youknowone Jan 13, 2026
2fe140f
Fix bytes/bytearray fromhex
youknowone Jan 13, 2026
db01a1d
Remove pickle from itertools
youknowone Jan 13, 2026
eafa0c0
Fix int rounding
youknowone Jan 13, 2026
24bff8d
fix unsigned validation
youknowone Jan 13, 2026
f5b44f5
Fix Exception.__init__
youknowone Jan 13, 2026
0793bd3
co_consts
youknowone Jan 13, 2026
fdfede7
fix win clippy
youknowone Jan 16, 2026
51b6286
PEP 649 annotation phase 1
youknowone Jan 13, 2026
353a9f6
PEP 649 annotation phase 2
youknowone Jan 13, 2026
a78b569
PEP 649 annotation phase 3
youknowone Jan 13, 2026
566b6f4
PEP 649 annotation phase 4
youknowone Jan 14, 2026
dc93614
Add annotationlib,ann_module from 3.14.2
youknowone Jan 15, 2026
37cc6b4
fix whats_left to support __annotate__
youknowone Jan 16, 2026
96038e4
partially patch inspect for PEP 649 in 3.13
youknowone Jan 14, 2026
346481d
partially patch Lib/typing to 3.14
youknowone Jan 15, 2026
076d692
Upgrade string from CPython 3.14.2
Jan 15, 2026
5227938
mark and unmark unittest functions
youknowone Jan 17, 2026
33689c1
Fix jit failure
youknowone Jan 14, 2026
65e08c0
Update ensurepip from 3.14.2
Jan 16, 2026
ef22bf4
Update _colorize from CPython 3.14.2
Jan 16, 2026
d75f272
Update argparse from CPython 3.14.2
Jan 16, 2026
314a615
Update calendar from CPython 3.14.2
Jan 16, 2026
133bdf6
auto_mark_test uses regex to check Run tests? sequentially
youknowone Jan 17, 2026
faeed2c
clean up
youknowone Jan 17, 2026
60fb438
Auto-format: ruff check --select I --fix
github-actions[bot] Jan 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update calendar from CPython 3.14.2
  • Loading branch information
CPython Devleopers authored and youknowone committed Jan 17, 2026
commit 314a61562c69bb3ca9f76ebf12699c696b9e4b6e
125 changes: 119 additions & 6 deletions Lib/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ def formatyear(self, theyear, w=2, l=1, c=6, m=3):
headers = (header for k in months)
a(formatstring(headers, colwidth, c).rstrip())
a('\n'*l)

# max number of weeks for this row
height = max(len(cal) for cal in row)
for j in range(height):
Expand Down Expand Up @@ -646,6 +647,117 @@ def formatmonthname(self, theyear, themonth, withyear=True):
with different_locale(self.locale):
return super().formatmonthname(theyear, themonth, withyear)


class _CLIDemoCalendar(TextCalendar):
def __init__(self, highlight_day=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.highlight_day = highlight_day

def formatweek(self, theweek, width, *, highlight_day=None):
"""
Returns a single week in a string (no newline).
"""
if highlight_day:
from _colorize import get_colors

ansi = get_colors()
highlight = f"{ansi.BLACK}{ansi.BACKGROUND_YELLOW}"
reset = ansi.RESET
else:
highlight = reset = ""

return ' '.join(
(
f"{highlight}{self.formatday(d, wd, width)}{reset}"
if d == highlight_day
else self.formatday(d, wd, width)
)
for (d, wd) in theweek
)

def formatmonth(self, theyear, themonth, w=0, l=0):
"""
Return a month's calendar string (multi-line).
"""
if (
self.highlight_day
and self.highlight_day.year == theyear
and self.highlight_day.month == themonth
):
highlight_day = self.highlight_day.day
else:
highlight_day = None
w = max(2, w)
l = max(1, l)
s = self.formatmonthname(theyear, themonth, 7 * (w + 1) - 1)
s = s.rstrip()
s += '\n' * l
s += self.formatweekheader(w).rstrip()
s += '\n' * l
for week in self.monthdays2calendar(theyear, themonth):
s += self.formatweek(week, w, highlight_day=highlight_day).rstrip()
s += '\n' * l
return s

def formatyear(self, theyear, w=2, l=1, c=6, m=3):
"""
Returns a year's calendar as a multi-line string.
"""
w = max(2, w)
l = max(1, l)
c = max(2, c)
colwidth = (w + 1) * 7 - 1
v = []
a = v.append
a(repr(theyear).center(colwidth*m+c*(m-1)).rstrip())
a('\n'*l)
header = self.formatweekheader(w)
for (i, row) in enumerate(self.yeardays2calendar(theyear, m)):
# months in this row
months = range(m*i+1, min(m*(i+1)+1, 13))
a('\n'*l)
names = (self.formatmonthname(theyear, k, colwidth, False)
for k in months)
a(formatstring(names, colwidth, c).rstrip())
a('\n'*l)
headers = (header for k in months)
a(formatstring(headers, colwidth, c).rstrip())
a('\n'*l)

if (
self.highlight_day
and self.highlight_day.year == theyear
and self.highlight_day.month in months
):
month_pos = months.index(self.highlight_day.month)
else:
month_pos = None

# max number of weeks for this row
height = max(len(cal) for cal in row)
for j in range(height):
weeks = []
for k, cal in enumerate(row):
if j >= len(cal):
weeks.append('')
else:
day = (
self.highlight_day.day if k == month_pos else None
)
weeks.append(
self.formatweek(cal[j], w, highlight_day=day)
)
a(formatstring(weeks, colwidth, c).rstrip())
a('\n' * l)
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()

Expand Down Expand Up @@ -698,7 +810,7 @@ def timegm(tuple):

def main(args=None):
import argparse
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(color=True)
textgroup = parser.add_argument_group('text only arguments')
htmlgroup = parser.add_argument_group('html only arguments')
textgroup.add_argument(
Expand Down Expand Up @@ -765,6 +877,7 @@ def main(args=None):
sys.exit(1)

locale = options.locale, options.encoding
today = datetime.date.today()

if options.type == "html":
if options.month:
Expand All @@ -781,23 +894,23 @@ def main(args=None):
optdict = dict(encoding=encoding, css=options.css)
write = sys.stdout.buffer.write
if options.year is None:
write(cal.formatyearpage(datetime.date.today().year, **optdict))
write(cal.formatyearpage(today.year, **optdict))
else:
write(cal.formatyearpage(options.year, **optdict))
else:
if options.locale:
cal = LocaleTextCalendar(locale=locale)
cal = _CLIDemoLocaleCalendar(highlight_day=today, locale=locale)
else:
cal = TextCalendar()
cal = _CLIDemoCalendar(highlight_day=today)
cal.setfirstweekday(options.first_weekday)
optdict = dict(w=options.width, l=options.lines)
if options.month is None:
optdict["c"] = options.spacing
optdict["m"] = options.months
if options.month is not None:
else:
_validate_month(options.month)
if options.year is None:
result = cal.formatyear(datetime.date.today().year, **optdict)
result = cal.formatyear(today.year, **optdict)
elif options.month is None:
result = cal.formatyear(options.year, **optdict)
else:
Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,11 @@ def assertFailure(self, *args):
self.assertCLIFails(*args)
self.assertCmdFails(*args)

@support.force_not_colorized
def test_help(self):
stdout = self.run_cmd_ok('-h')
self.assertIn(b'usage:', stdout)
self.assertIn(b'calendar.py', stdout)
self.assertIn(b' -m calendar ', stdout)
self.assertIn(b'--help', stdout)

# special case: stdout but sys.exit()
Expand Down Expand Up @@ -1089,6 +1090,7 @@ def test_option_months(self):
output = run('--months', '1', '2004')
self.assertIn(conv('\nMo Tu We Th Fr Sa Su\n'), output)

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_option_type(self):
self.assertFailure('-t')
self.assertFailure('--type')
Expand All @@ -1097,7 +1099,7 @@ def test_option_type(self):
output = run('--type', 'text', '2004')
self.assertEqual(output, conv(result_2004_text))
output = run('--type', 'html', '2004')
self.assertEqual(output[:6], b'<?xml ')
self.assertStartsWith(output, b'<?xml ')
self.assertIn(b'<title>Calendar for 2004</title>', output)

def test_html_output_current_year(self):
Expand Down