[Python-checkins] cpython (3.2): Issue #1813: Fix codec lookup under Turkish locales.
antoine.pitrou
python-checkins at python.org
Sun Jul 24 02:43:22 CEST 2011
http://hg.python.org/cpython/rev/92d02de91cc9
changeset: 71489:92d02de91cc9
branch: 3.2
parent: 71487:9f847dfba217
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sun Jul 24 02:27:04 2011 +0200
summary:
Issue #1813: Fix codec lookup under Turkish locales.
files:
Lib/test/test_codecs.py | 14 ++++++++++++++
Misc/NEWS | 2 ++
Python/codecs.c | 2 +-
3 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -1,6 +1,7 @@
from test import support
import unittest
import codecs
+import locale
import sys, _testcapi, io
class Queue(object):
@@ -1230,6 +1231,19 @@
self.assertRaises(TypeError, codecs.getwriter)
self.assertRaises(LookupError, codecs.getwriter, "__spam__")
+ def test_lookup_issue1813(self):
+ # Issue #1813: under Turkish locales, lookup of some codecs failed
+ # because 'I' is lowercased as "ı" (dotless i)
+ oldlocale = locale.getlocale(locale.LC_CTYPE)
+ self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
+ try:
+ locale.setlocale(locale.LC_CTYPE, 'tr_TR')
+ except locale.Error:
+ # Unsupported locale on this system
+ self.skipTest('test needs Turkish locale')
+ c = codecs.lookup('ASCII')
+ self.assertEqual(c.name, 'ascii')
+
class StreamReaderTest(unittest.TestCase):
def setUp(self):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,8 @@
Library
-------
+- Issue #1813: Fix codec lookup under Turkish locales.
+
- Issue #12591: Improve support of "universal newlines" in the subprocess
module: the piped streams can now be properly read from or written to.
diff --git a/Python/codecs.c b/Python/codecs.c
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -69,7 +69,7 @@
if (ch == ' ')
ch = '-';
else
- ch = tolower(Py_CHARMASK(ch));
+ ch = Py_TOLOWER(Py_CHARMASK(ch));
p[i] = ch;
}
p[i] = '\0';
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list