Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
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 78935da (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 <[email protected]> Co-authored-by: Jessica McKellar <[email protected]> Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Irit Katriel <[email protected]>
- Loading branch information