File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from test import support
22import unittest
33import codecs
4+ import locale
45import sys , _testcapi , io
56
67class Queue (object ):
@@ -1230,6 +1231,19 @@ def test_getwriter(self):
12301231 self .assertRaises (TypeError , codecs .getwriter )
12311232 self .assertRaises (LookupError , codecs .getwriter , "__spam__" )
12321233
1234+ def test_lookup_issue1813 (self ):
1235+ # Issue #1813: under Turkish locales, lookup of some codecs failed
1236+ # because 'I' is lowercased as "ı" (dotless i)
1237+ oldlocale = locale .getlocale (locale .LC_CTYPE )
1238+ self .addCleanup (locale .setlocale , locale .LC_CTYPE , oldlocale )
1239+ try :
1240+ locale .setlocale (locale .LC_CTYPE , 'tr_TR' )
1241+ except locale .Error :
1242+ # Unsupported locale on this system
1243+ self .skipTest ('test needs Turkish locale' )
1244+ c = codecs .lookup ('ASCII' )
1245+ self .assertEqual (c .name , 'ascii' )
1246+
12331247class StreamReaderTest (unittest .TestCase ):
12341248
12351249 def setUp (self ):
Original file line number Diff line number Diff line change @@ -391,6 +391,19 @@ def test_setlocale_category(self):
391391 # crasher from bug #7419
392392 self .assertRaises (locale .Error , locale .setlocale , 12345 )
393393
394+ def test_getsetlocale_issue1813 (self ):
395+ # Issue #1813: setting and getting the locale under a Turkish locale
396+ oldlocale = locale .getlocale ()
397+ self .addCleanup (locale .setlocale , locale .LC_CTYPE , oldlocale )
398+ try :
399+ locale .setlocale (locale .LC_CTYPE , 'tr_TR' )
400+ except locale .Error :
401+ # Unsupported locale on this system
402+ self .skipTest ('test needs Turkish locale' )
403+ loc = locale .getlocale ()
404+ locale .setlocale (locale .LC_CTYPE , loc )
405+ self .assertEqual (loc , locale .getlocale ())
406+
394407
395408def test_main ():
396409 tests = [
Original file line number Diff line number Diff line change @@ -237,6 +237,8 @@ Core and Builtins
237237Library
238238-------
239239
240+ - Issue #1813: Fix codec lookup under Turkish locales.
241+
240242- Issue #12591: Improve support of "universal newlines" in the subprocess
241243 module: the piped streams can now be properly read from or written to.
242244
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ PyObject *normalizestring(const char *string)
6969 if (ch == ' ' )
7070 ch = '-' ;
7171 else
72- ch = tolower (Py_CHARMASK (ch ));
72+ ch = Py_TOLOWER (Py_CHARMASK (ch ));
7373 p [i ] = ch ;
7474 }
7575 p [i ] = '\0' ;
You can’t perform that action at this time.
0 commit comments