#10092: Properly reset locale in Locale*Calendar classes. The context manager was buggy because setlocale() returns the *new* locale, not the old. Also add a test for this.

This commit is contained in:
Georg Brandl 2010-10-19 18:54:25 +00:00
parent f87cc04481
commit 7004bd1a3d
4 changed files with 30 additions and 5 deletions

View file

@ -486,8 +486,8 @@ class different_locale:
self.locale = locale
def __enter__(self):
self.oldlocale = _locale.setlocale(_locale.LC_TIME, self.locale)
#return _locale.getlocale(_locale.LC_TIME)[1]
self.oldlocale = _locale.getlocale(_locale.LC_TIME)
_locale.setlocale(_locale.LC_TIME, self.locale)
def __exit__(self, *args):
_locale.setlocale(_locale.LC_TIME, self.oldlocale)