Skip to content

Commit 4912719

Browse files
!fixup merge
1 parent 8d50a7e commit 4912719

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Python/codecs.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,20 @@ normalizestring(const char *string)
101101
return NULL;
102102
}
103103

104-
encoding = PyMem_Malloc(len + 1);
105-
if (encoding == NULL) {
104+
p = PyMem_Malloc(len + 1);
105+
if (p == NULL)
106106
return PyErr_NoMemory();
107-
}
108-
109-
if (!_Py_normalize_encoding(string, encoding, len + 1, 1))
110-
{
111-
PyErr_SetString(PyExc_RuntimeError, "_Py_normalize_encoding() failed");
112-
PyMem_Free(encoding);
113-
return NULL;
114-
}
115-
116-
v = PyUnicode_FromString(encoding);
117-
PyMem_Free(encoding);
107+
for (i = 0; i < len; i++) {
108+
char ch = string[i];
109+
if (ch == ' ')
110+
ch = '-';
111+
else
112+
ch = Py_TOLOWER(Py_CHARMASK(ch));
113+
p[i] = ch;
114+
}
115+
p[i] = '\0';
116+
v = PyUnicode_FromString(p);
117+
PyMem_Free(p);
118118
return v;
119119
}
120120

0 commit comments

Comments
 (0)