[Python-checkins] cpython (2.7): The simplest possible fix for the regression in bug 12752 by encoding unicodes
barry.warsaw
python-checkins at python.org
Tue Aug 16 01:51:00 CEST 2011
http://hg.python.org/cpython/rev/0d64fe6c737f
changeset: 71873:0d64fe6c737f
branch: 2.7
parent: 71871:fb49394f75ed
user: Barry Warsaw <barry at python.org>
date: Mon Aug 15 19:17:12 2011 -0400
summary:
The simplest possible fix for the regression in bug 12752 by encoding unicodes
to 8-bit strings.
files:
Lib/locale.py | 2 ++
Lib/test/test_locale.py | 5 +++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/Lib/locale.py b/Lib/locale.py
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -355,6 +355,8 @@
"""
# 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
--- a/Lib/test/test_locale.py
+++ b/Lib/test/test_locale.py
@@ -412,6 +412,11 @@
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 = [
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list