Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-131146: Fix month names in a genitive case in calendar module#131147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
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 monthis 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 casewhere available.
ghost commentedMar 12, 2025 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
There was a problem hiding this 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 (checkLib/test/test_calendar.py
)
Uh oh!
There was an error while loading.Please reload this page.
… and `calendar.alt_month_abbr` to `calendar.standalone_month_abbr`.
* Limit line length to 79 characters according to PEP8* Suppress current unit links according to the Documentation Style Guide
Misc/NEWS.d/next/Library/2025-03-17-21-15-04.gh-issue-131146.P9Cdx0.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
A sequence that represents the months of the year in the current locale. | ||
Thisfollows normal convention of January being month number 1, so it has | ||
a length of13 and ``month_name[0]`` is the empty string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is just a formatting change and should not be included in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It's to limit the line length to 80 characters in accordance with thereStructuredText markup guideline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Again, you did not modify this section, please revert it. Existing violations do not have to be fixed, I assure you there are hundreds in the file.
locale. This follows normal convention of January being month number 1, so | ||
ithas a length of 13 and ``month_abbr[0]`` is the empty string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Again unrelated formatting changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It's to limit the line length to 80 characters in accordance with thereStructuredText markup guideline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You did not modify this section, it is unrelated to this pr, please revert it.
Uh oh!
There was an error while loading.Please reload this page.
try: | ||
standalone_month_name = _localized_month('%OB') | ||
standalone_month_abbr = _localized_month('%Ob') | ||
except ValueError: | ||
# The platform does not support the %OB and %Ob specifiers. | ||
standalone_month_name = month_name | ||
standalone_month_abbr = month_abbr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
try: | |
standalone_month_name=_localized_month('%OB') | |
standalone_month_abbr=_localized_month('%Ob') | |
exceptValueError: | |
# The platform does not support the %OB and %Ob specifiers. | |
standalone_month_name=month_name | |
standalone_month_abbr=month_abbr | |
try: | |
standalone_month_name=_localized_month('%OB') | |
standalone_month_abbr=_localized_month('%Ob') | |
exceptValueError: | |
standalone_month_name=month_name | |
standalone_month_abbr=month_abbr |
The previous comment covers this IMO
Add :data:`calendar.standalone_month_name` and :data:`calendar.standalone_month_abbr` to | ||
provide month names and abbreviations in a grammatical form used when a month name stands | ||
by itself if the locale provides one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Both the NEWS entries are for the same issue, they could just be merged. "Fix ... by adding :data:calendar.standalone_month_name
and :data:calendar.standalone_month_abbr
. These provide ... "
Uh oh!
There was an error while loading.Please reload this page.
bedevere-bot commentedApr 29, 2025
🤖 New build scheduled with the buildbot fleet by@encukou for commit36bb456 🤖 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 commentedApr 29, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thank you for the PR,@plashchynski |
This also needs a proper test (my comment was incorrectly closed) using |
Uh oh!
There was an error while loading.Please reload this page.
>>> import calendar | ||
>>> list(calendar.standalone_month_name) | ||
['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] | ||
StanFromIrelandApr 29, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This example is pointless in the English locale, and it links tomonth_name
with the exact same example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I agree, it's not relevant for English. But which locale should I use here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We do not have to provide an example.
>>> import calendar | ||
>>> list(calendar.standalone_month_abbr) | ||
['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ditto
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Doc/library/calendar.rst Outdated
A sequence that represents the months of the year in the current locale | ||
in the grammatical form used when a month name stands by itself if the locale | ||
provides one. If the locale does not supply an alternative form, it is equal to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
A sequence that represents the months of the year in the current locale | |
in the grammatical form used when a month name stands by itself if the locale | |
provides one. If the locale does not supply an alternative form, it is equal to | |
A sequence that represents the months of the year in the current locale | |
in the standalone form if the locale provides one. Else it is equivalent to |
Much simpler format, as docs should bee.g.
Doc/library/calendar.rst Outdated
A sequence that represents the months of the year in the current locale | ||
in the grammatical form used when a month name stands by itself if the locale | ||
provides one. If the locale does not supply an alternative form, it is equal to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
A sequence that represents the months of the year in the current locale | |
in the grammatical form used when a month name stands by itself if the locale | |
provides one. If the locale does not supply an alternative form, it is equal to | |
A sequence that represents the months of the year in the current locale | |
in the standalone form if the locale provides one. Else it is equivalent to |
Much simpler format, as docs should bee.g.
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? |
This comment was marked as resolved.
This comment was marked as resolved.
The problem is specific only to certain locales. To properly test it, we need to have these locales installed. A test with |
It will not pass, it will be skipped.
It is! Most systems have locale like |
plashchynski commentedMay 11, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Even if the system has Given this, how could we distinguish the wrong behaviour from the fallback route? |
One trick would be to check for some common platform that does support ifplatform.libc_ver()[0]=='glibc':"Polish month 2 MUST be 'luty'"else:"Polish month 2 could be either 'luty' or 'lut'" |
Uh oh!
There was an error while loading.Please reload this page.
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
andalt_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.