Skip to content

gh-148663: Document that IllegalMonthError inherits from both ValueError and IndexError#148664

Open
EoinTrial wants to merge 3 commits intopython:mainfrom
EoinTrial:fix/calendar-illegalmontherror-docs
Open

gh-148663: Document that IllegalMonthError inherits from both ValueError and IndexError#148664
EoinTrial wants to merge 3 commits intopython:mainfrom
EoinTrial:fix/calendar-illegalmontherror-docs

Conversation

@EoinTrial
Copy link
Copy Markdown

@EoinTrial EoinTrial commented Apr 17, 2026

The documentation for calendar.IllegalMonthError describes it only as "a subclass of ValueError", but the source code defines it as:

class IllegalMonthError(ValueError, IndexError):

The IndexError base class is intentional for backwards compatibility (see the source comment in Lib/calendar.py), but this is not mentioned in the docs. Users catching IndexError for bad month numbers won't know their code still works after Python 3.13.


📚 Documentation preview 📚: https://cpython-previews--148664.org.readthedocs.build/

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented Apr 17, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@picnixz
Copy link
Copy Markdown
Member

picnixz commented Apr 19, 2026

  1. Can you add a versionchanged directive indicating that this is now inheriting ValuerError and IndexError since 3.13 (I did not check when it was changed so pick the correct version).
  2. Reword the NEWS entry
  3. Add a test to ensure that we do not remove that double inheritance.

@EoinTrial EoinTrial force-pushed the fix/calendar-illegalmontherror-docs branch from 58e98ba to 1781682 Compare April 19, 2026 14:32
@EoinTrial EoinTrial requested a review from AA-Turner as a code owner April 19, 2026 14:32
@EoinTrial
Copy link
Copy Markdown
Author

@picnixz Thanks for taking a look! I've added the versionchanged:: 3.12 directive, rewritten the NEWS entry, and added test_illegal_month_error_bases to verify the dual inheritance.

Comment thread Doc/library/calendar.rst Outdated
Comment thread Doc/library/calendar.rst Outdated
Comment thread Doc/library/calendar.rst Outdated
Comment thread Lib/test/test_calendar.py Outdated
@EoinTrial EoinTrial force-pushed the fix/calendar-illegalmontherror-docs branch from 1781682 to c4e2753 Compare April 19, 2026 16:46
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@EoinTrial EoinTrial requested a review from picnixz April 19, 2026 16:48
@EoinTrial
Copy link
Copy Markdown
Author

@picnixz Thanks very much for reviewing! What's the next step towards getting this merged? :)

@picnixz
Copy link
Copy Markdown
Member

picnixz commented Apr 21, 2026

I need to come back home so a week or so. In general, once it is approved by one core dev, if the change is minimal, it will be merged when they have time. On your side there is nothing to do (we will ourselves update the branch if necessary/

@picnixz
Copy link
Copy Markdown
Member

picnixz commented Apr 21, 2026

There are however some lint issues so could you fix them please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants