Skip to content

Commit 58e98ba

Browse files
committed
gh-148663: Document that IllegalMonthError inherits from both ValueError and IndexError
1 parent 2a07ff9 commit 58e98ba

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Doc/library/calendar.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,11 @@ The :mod:`!calendar` module defines the following exceptions:
580580

581581
.. exception:: IllegalMonthError(month)
582582

583-
A subclass of :exc:`ValueError`,
583+
A subclass of both :exc:`ValueError` and :exc:`IndexError`,
584584
raised when the given month number is outside of the range 1-12 (inclusive).
585+
The :exc:`IndexError` base class is preserved for backwards compatibility
586+
with code that caught :exc:`IndexError` for bad month numbers prior to
587+
Python 3.13.
585588

586589
.. attribute:: month
587590

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Document that :class:`calendar.IllegalMonthError` inherits from both
2+
:exc:`ValueError` and :exc:`IndexError`, preserving :exc:`IndexError` for
3+
backwards compatibility with code that caught it for bad month numbers prior
4+
to Python 3.13.
5+
###########################################################################

0 commit comments

Comments
 (0)