diff -r ab3432a81c26 Lib/test/string_tests.py --- a/Lib/test/string_tests.py Sun Aug 14 08:28:57 2011 +0300 +++ b/Lib/test/string_tests.py Sun Aug 14 20:56:03 2011 +0300 @@ -641,6 +641,22 @@ self.checkequal('Aaaa', 'aaaa', 'capitalize') self.checkequal('Aaaa', 'AaAa', 'capitalize') + # check that title-cased chars are lowered correctly + self.checkequal('\u1ffc\u1ff3\u1ff3\u1ff3', + '\u1ff3\u1ff3\u1ffc\u1ffc', 'capitalize') + # check with non-letter chars + self.checkequal('\u24c5\u24e8\u24e3\u24d7\u24de\u24dd', + '\u24c5\u24ce\u24c9\u24bd\u24c4\u24c3', 'capitalize') + self.checkequal('\u24c5\u24e8\u24e3\u24d7\u24de\u24dd', + '\u24df\u24e8\u24e3\u24d7\u24de\u24dd', 'capitalize') + self.checkequal('\u2160\u2171\u2172', + '\u2160\u2161\u2162', 'capitalize') + self.checkequal('\u2160\u2171\u2172', + '\u2170\u2171\u2172', 'capitalize') + # check with Ll chars with no upper + self.checkequal('\u019b\u1d00\u1d86\u0221\u1fb7', + '\u019b\u1d00\u1d86\u0221\u1fb7', 'capitalize') + self.checkraises(TypeError, 'hello', 'capitalize', 42) def test_lower(self): diff -r ab3432a81c26 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Sun Aug 14 08:28:57 2011 +0300 +++ b/Objects/unicodeobject.c Sun Aug 14 20:56:03 2011 +0300 @@ -6658,13 +6658,13 @@ if (len == 0) return 0; - if (Py_UNICODE_ISLOWER(*s)) { + if (!Py_UNICODE_ISUPPER(*s)) { *s = Py_UNICODE_TOUPPER(*s); status = 1; } s++; while (--len> 0) { - if (Py_UNICODE_ISUPPER(*s)) { + if (!Py_UNICODE_ISLOWER(*s)) { *s = Py_UNICODE_TOLOWER(*s); status = 1; }

AltStyle によって変換されたページ (->オリジナル) /