#12266: Fix str.capitalize() to correctly uppercase/lowercase titlecased and cased non-letter characters.

This commit is contained in:
Ezio Melotti 2011-08-15 09:09:57 +03:00
parent 388c945e97
commit ee8d998ecf
3 changed files with 31 additions and 2 deletions

View file

@ -6658,13 +6658,13 @@ int fixcapitalize(PyUnicodeObject *self)
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;
}