gh-148663: Document that IllegalMonthError inherits from both ValueError and IndexError#148664
Open
EoinTrial wants to merge 2 commits intopython:mainfrom
Open
gh-148663: Document that IllegalMonthError inherits from both ValueError and IndexError#148664EoinTrial wants to merge 2 commits intopython:mainfrom
EoinTrial wants to merge 2 commits intopython:mainfrom
Conversation
|
The following commit authors need to sign the Contributor License Agreement: |
Member
|
58e98ba to
1781682
Compare
Author
|
@picnixz Thanks for taking a look! I've added the |
picnixz
reviewed
Apr 19, 2026
| Python 3.13. | ||
|
|
||
| .. versionchanged:: 3.12 | ||
| :exc:`IllegalMonthError` is now also a subclass of :exc:`IndexError`. |
Member
There was a problem hiding this comment.
Suggested change
| :exc:`IllegalMonthError` is now also a subclass of :exc:`IndexError`. | |
| :exc:`IllegalMonthError`is now also a subclass of :exc:`ValueError`. Newer code should avoid catching :exc:`IndexError`. |
And make that paragraph fit on 80 chars.
| calendar.TextCalendar().formatmonth(2017, -1) | ||
|
|
||
| def test_illegal_month_error_bases(self): | ||
| self.assertTrue(issubclass(calendar.IllegalMonthError, ValueError)) |
Member
There was a problem hiding this comment.
There is a helper assertIsSubclass
…alueError and IndexError
1781682 to
c4e2753
Compare
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The documentation for
calendar.IllegalMonthErrordescribes it only as "a subclass ofValueError", but the source code defines it as:The
IndexErrorbase class is intentional for backwards compatibility (see the source comment inLib/calendar.py), but this is not mentioned in the docs. Users catchingIndexErrorfor bad month numbers won't know their code still works after Python 3.13.calendar.IllegalMonthErrordocs omit IndexError base class #148663📚 Documentation preview 📚: https://cpython-previews--148664.org.readthedocs.build/