Skip to content

Commit eeca56a

Browse files
committed
gh-153158: Remove the erroneous width argument of HTMLCalendar.formatmonthpage
The argument is a meaningless copy-paste from formatyearpage; a single month has no width. formatmonthpage is new in 3.15 (currently unreleased at 3.15.0b3), so remove it rather than keep a broken argument.
1 parent 0621639 commit eeca56a

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

Lib/calendar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,11 @@ def formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None):
609609
content = self.formatyear(theyear, width)
610610
return self._format_html_page(theyear, content, css, encoding)
611611

612-
def formatmonthpage(self, theyear, themonth, width=3, css='calendar.css', encoding=None):
612+
def formatmonthpage(self, theyear, themonth, css='calendar.css', encoding=None):
613613
"""
614614
Return a formatted month as a complete HTML page.
615615
"""
616-
content = self.formatmonth(theyear, themonth, width)
616+
content = self.formatmonth(theyear, themonth)
617617
return self._format_html_page(theyear, content, css, encoding)
618618

619619

Lib/test/test_calendar.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,12 @@ def test_format_html_year_with_month(self):
545545
result_2009_6_html
546546
)
547547

548+
def test_formatmonthpage_no_width(self):
549+
# gh-140212: formatmonthpage must not accept a 'width' argument.
550+
cal = calendar.HTMLCalendar()
551+
self.assertIn(b'class="month">June 2009', cal.formatmonthpage(2009, 6))
552+
self.assertRaises(TypeError, cal.formatmonthpage, 2009, 6, width=3)
553+
548554

549555
class CalendarTestCase(unittest.TestCase):
550556

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove the erroneous *width* argument of
2+
:meth:`calendar.HTMLCalendar.formatmonthpage`, which could drop the year from
3+
the heading.

0 commit comments

Comments
 (0)