diff options
author | Barry Warsaw <barry@python.org> | 2011-08-15 23:17:12 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2011-08-15 23:17:12 (GMT) |
commit | edfba8244c6ec1a7aceeff69e304489478d9d7c7 (patch) | |
tree | a951f506150314328d222110328d8b5fd1a905d1 | |
parent | 5085e8ac67ba38527daf4537747a5f876f6e2da6 (diff) | |
download | cpython-edfba8244c6ec1a7aceeff69e304489478d9d7c7.zip cpython-edfba8244c6ec1a7aceeff69e304489478d9d7c7.tar.gz cpython-edfba8244c6ec1a7aceeff69e304489478d9d7c7.tar.bz2 |
The simplest possible fix for the regression in bug 12752 by encoding unicodes
to 8-bit strings.
-rw-r--r-- | Lib/locale.py | 2 | ||||
-rw-r--r-- | Lib/test/test_locale.py | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Lib/locale.py b/Lib/locale.py index 166538d..0c4d652 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -355,6 +355,8 @@ def normalize(localename): """ # Normalize the locale name and extract the encoding + if isinstance(localename, unicode): + localename = localename.encode('ascii') fullname = localename.translate(_ascii_lower_map) if ':' in fullname: # ':' is sometimes used as encoding delimiter. diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index 718bbf4..a88d34b 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -412,6 +412,11 @@ class TestMiscellaneous(unittest.TestCase): locale.setlocale(locale.LC_CTYPE, loc) self.assertEqual(loc, locale.getlocale()) + def test_normalize_issue12752(self): + # Issue #1813 caused a regression where locale.normalize() would no + # longer accept unicode strings. + self.assertEqual(locale.normalize(u'en_US'), 'en_US.ISO8859-1') + def test_main(): tests = [ |