]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #1813: Fix codec lookup under Turkish locales.
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 24 Jul 2011 00:27:04 +0000 (02:27 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 24 Jul 2011 00:27:04 +0000 (02:27 +0200)
Lib/test/test_codecs.py
Misc/NEWS
Python/codecs.c

index 6c7d44bec63762f6ca0b66ea7bcd96ea70a9109c..6b84023d236b857b2e3faac0c5a29ae7f180d447 100644 (file)
@@ -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 @@ class CodecsModuleTest(unittest.TestCase):
         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):
index c7e917e045f412f1285824da316f1dcb6bb8eb04..4513f9aec0e8f7dd044cf7493efca6f9363cdd7b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,8 @@ Core and Builtins
 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.
 
index 45d99291f11e7f1b09174aca23bc131e7450aa24..1a3e45774cb8f7c9e45606070d2caa5ad19fd1b2 100644 (file)
@@ -69,7 +69,7 @@ PyObject *normalizestring(const char *string)
         if (ch == ' ')
             ch = '-';
         else
-            ch = tolower(Py_CHARMASK(ch));
+            ch = Py_TOLOWER(Py_CHARMASK(ch));
         p[i] = ch;
     }
     p[i] = '\0';