diff options
author | Bart Skowron <bart@bxsx.dev> | 2023-07-22 15:20:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-22 15:20:40 +0200 |
commit | 2aba047f0a2be57cc33a57756707452fdd6a1b3f (patch) | |
tree | b638e1823275eb965ff6b6ac688aa62b0a0366fb /Python/Python-tokenize.c | |
parent | 463b56da1265a17e4207f651d6d5835a8d6de2dd (diff) | |
download | cpython-2aba047f0a2be57cc33a57756707452fdd6a1b3f.tar.gz cpython-2aba047f0a2be57cc33a57756707452fdd6a1b3f.zip |
gh-69714: Make `calendar` module fully tested (#93655)
There are 3 paths to use `locale` argument in
`calendar.Locale{Text|HTML}Calendar.__init__(..., locale=None)`:
(1) `locale=None` -- denotes the "default locale"[1]
(2) `locale=""` -- denotes the native environment
(3) `locale=other_valid_locale` -- denotes a custom locale
So far case (2) is covered and case (1) is in 78935daf5a (same branch).
This commit adds a remaining case (3).
[1] In the current implementation, this translates into the following
approach:
GET current locale
IF current locale == "C" THEN
SET current locale TO ""
GET current locale
ENDIF
* Remove unreachable code (and increase test coverage)
This condition cannot be true. `_locale.setlocale()` from the C module
raises `locale.Error` instead of returning `None` for
`different_locale.__enter__` (where `self.oldlocale` is set).
* Expand the try clause to calls to `LocaleTextCalendar.formatmonthname()`.
This method temporarily changes the current locale to the given locale,
so `_locale.setlocale()` may raise `local.Error`.
Co-authored-by: Rohit Mediratta <rohitm@gmail.com>
Co-authored-by: Jessica McKellar <jesstess@mit.edu>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Python/Python-tokenize.c')
0 files changed, 0 insertions, 0 deletions