Commit 2aba047
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]>
1 parent 463b56d commit 2aba047
File tree
4 files changed
+204
-54
lines changed- Lib
- test
- Misc
- NEWS.d/next/Tests
4 files changed
+204
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
585 | 585 | | |
586 | 586 | | |
587 | 587 | | |
588 | | - | |
589 | | - | |
590 | 588 | | |
591 | 589 | | |
592 | 590 | | |
| |||
690 | 688 | | |
691 | 689 | | |
692 | 690 | | |
693 | | - | |
| 691 | + | |
694 | 692 | | |
695 | 693 | | |
696 | 694 | | |
| |||
747 | 745 | | |
748 | 746 | | |
749 | 747 | | |
750 | | - | |
| 748 | + | |
751 | 749 | | |
752 | 750 | | |
753 | 751 | | |
| |||
756 | 754 | | |
757 | 755 | | |
758 | 756 | | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
759 | 760 | | |
760 | 761 | | |
761 | 762 | | |
| |||
767 | 768 | | |
768 | 769 | | |
769 | 770 | | |
770 | | - | |
771 | | - | |
772 | 771 | | |
773 | | - | |
774 | | - | |
| 772 | + | |
775 | 773 | | |
776 | 774 | | |
777 | 775 | | |
| |||
795 | 793 | | |
796 | 794 | | |
797 | 795 | | |
798 | | - | |
| 796 | + | |
0 commit comments