bpo-46659: calendar uses locale.getlocale()#31166
bpo-46659: calendar uses locale.getlocale()#31166vstinner merged 2 commits intopython:mainfrom vstinner:calendar_defaultlocale
Conversation
The calendar.LocaleTextCalendar and calendar.LocaleHTMLCalendar classes module now use locale.getlocale(), instead of using locale.getdefaultlocale(), if no locale is specified.
|
Example with cal_locale.py attached to bpo-46659. Run the program in English, but switch to a french locale before creating the LocaleTextCalendar() instance. Current behavior: calendar speaks English, even if the current LC_TIME locale is French: With this PR: calendar speaks French: Applications which don't call setlocale() to change the LC_ALL or LC_TIME locale are not affected. |
|
Would not be more correct to use |
|
With this PR, the two classes store the current locale when an instance is created. Is it really an important feature? Or would it be acceptable to use the current locale (don't change the locale) if locale=None is passed (default behavior)? |
You're right: done. |
|
Merged, thanks for your reviews.
In case of doubt, I prefer to leave the code as it is. |
The calendar.LocaleTextCalendar and calendar.LocaleHTMLCalendar
classes module now use locale.getlocale(), instead of using
locale.getdefaultlocale(), if no locale is specified.
https://bugs.python.org/issue46659