Skip to content

gh-131146: Fix month names in a genitive case in calendar module#131147

Merged
encukou merged 19 commits intopython:mainfrom
plashchynski:fix_calendar_genitive_case
Jul 31, 2025
Merged

gh-131146: Fix month names in a genitive case in calendar module#131147
encukou merged 19 commits intopython:mainfrom
plashchynski:fix_calendar_genitive_case

Conversation

@plashchynski
Copy link
Copy Markdown
Contributor

@plashchynski plashchynski commented Mar 12, 2025

The calendar module displays month names in some locales using the genitive case. This is grammatically incorrect, as the nominative case should be used when the month is named by itself. To address this issue, this change introduces new lists alt_month_name and alt_month_abbr that contain month names in the nominative case. The module now uses %OB format specifier to get month names in the nominative case where available.

The calendar module displays month names in some locales using the genitive case.
This is grammatically incorrect, as the nominative case should be used when the month
is named by itself. To address this issue, this change introduces new lists
`alt_month_name` and `alt_month_abbr` that contain month names in the nominative case.
The module now uses `%OB` format specifier to get month names in the nominative case
where available.
@ghost
Copy link
Copy Markdown

ghost commented Mar 12, 2025

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Mar 12, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Copy Markdown
Member

@tomasr8 tomasr8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! This will also need a NEWS entry and tests (check Lib/test/test_calendar.py)

Comment thread Lib/calendar.py Outdated
Comment thread Doc/library/calendar.rst Outdated
Comment thread Doc/library/calendar.rst Outdated
Comment thread Lib/calendar.py
Comment thread Lib/calendar.py
Comment thread Misc/NEWS.d/next/Library/2025-03-17-21-15-04.gh-issue-131146.P9Cdx0.rst Outdated
Comment thread Lib/test/test_calendar.py
@bedevere-bot
Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit 36bb456 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F131147%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@encukou
Copy link
Copy Markdown
Member

encukou commented Apr 29, 2025

Thank you for the PR, @plashchynski
If you don't beat me to it, I plan to fix the formatting/comments/entries tomorrow so that this gets into 3.14.

@StanFromIreland
Copy link
Copy Markdown
Member

This also needs a proper test (my comment was incorrectly closed) using support's @run_with_locale, grep the existing tests for usage examples, there are quite a few.

Comment thread Doc/library/calendar.rst Outdated
Comment thread Doc/library/calendar.rst Outdated
Comment thread Doc/library/calendar.rst Outdated
Comment thread Lib/calendar.py Outdated
Comment thread Doc/library/calendar.rst Outdated
Comment thread Doc/library/calendar.rst Outdated
Comment thread Doc/library/calendar.rst Outdated
@StanFromIreland
Copy link
Copy Markdown
Member

I can finish this off if you are unable to, it should still be backported to 3.14 since it is a bug fix, no?

@StanFromIreland

This comment was marked as resolved.

@plashchynski
Copy link
Copy Markdown
Contributor Author

This also needs a proper test (my comment was incorrectly closed) using support's @run_with_locale, grep the existing tests for usage examples, there are quite a few.

The problem is specific only to certain locales. To properly test it, we need to have these locales installed. A test with @run_with_locale will fail only on systems where that locales are installed. So for most systems that test will be green without proposed changes. I think it's not worth to add tests that can't fail on most of the systems.

@StanFromIreland
Copy link
Copy Markdown
Member

So for most systems that test will be green without proposed changes.

It will not pass, it will be skipped.

I think it's not worth to add tests that can't fail on most of the systems.

It is! Most systems have locale like pl_PL installed anyway, looking at the buildbots the majority do.

@plashchynski
Copy link
Copy Markdown
Contributor Author

plashchynski commented May 11, 2025

I think it's not worth to add tests that can't fail on most of the systems.

It is! Most systems have locale like pl_PL installed anyway, looking at the buildbots the majority do.

Even if the system has pl_PL installed, it's possible that it doesn't support %OB %Ob extensions. And we don't know for sure weather it supported or not.

Given this, how could we distinguish the wrong behaviour from the fallback route?
I mean, if we test for the standalone form, it's possible that the regular form is returned because of the fallback.
Hope it makes sense.

@encukou
Copy link
Copy Markdown
Member

encukou commented May 19, 2025

One trick would be to check for some common platform that does support %OB, for example:

if platform.libc_ver()[0] == 'glibc':
    "Polish month 2 MUST be 'luty'"
else:
    "Polish month 2 could be either 'luty' or 'lut'"

@serhiy-storchaka
Copy link
Copy Markdown
Member

The test should check for example that calendar.standalone_month_name[5] is contained in the calendar output for May. It can also skip if calendar.standalone_month_name[5] == calendar.month_name[5].

@plashchynski
Copy link
Copy Markdown
Contributor Author

I've added a new test test_standalone_month_name_and_abbr_pl_locale to verify the standalone month names and abbrs specifically in pl_PL. Please check.

Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@encukou
Copy link
Copy Markdown
Member

encukou commented Jul 31, 2025

Thank you for seeing this through, @plashchynski!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants