Mercurial > cpython-lru_cache-weakref
diff Python/getargs.c @ 43961:b231bda653a4
PyString_AsString is permissive and accepts unicode strings.
Replace it with PyUnicode_AsString when the argument is known to be a str.
| author | Amaury Forgeot d'Arc <amauryfa@gmail.com> |
|---|---|
| date | Thu, 22 Nov 2007 02:48:12 +0000 |
| parents | ddbc5e2c689a |
| children | 664b0bc92b96 |
line wrap: on
line diff
--- a/Python/getargs.c Thu Nov 22 01:09:33 2007 +0000 +++ b/Python/getargs.c Thu Nov 22 02:48:12 2007 +0000 @@ -768,7 +768,7 @@ else if (PyUnicode_Check(arg) && PyUnicode_GET_SIZE(arg) == 1 && PyUnicode_AS_UNICODE(arg)[0] < 256) - *p = PyUnicode_AS_UNICODE(arg)[0]; + *p = (char)PyUnicode_AS_UNICODE(arg)[0]; else return converterr("char < 256", arg, msgbuf, bufsize); break; @@ -823,7 +823,7 @@ } else return converterr("string", arg, msgbuf, bufsize); - if ((Py_ssize_t)strlen(*p) != PyString_Size(arg)) + if ((Py_ssize_t)strlen(*p) != PyUnicode_GetSize(arg)) return converterr("string without null bytes", arg, msgbuf, bufsize); } @@ -899,7 +899,7 @@ format++; } else if (*p != NULL && - (Py_ssize_t)strlen(*p) != PyString_Size(arg)) + (Py_ssize_t)strlen(*p) != PyUnicode_GetSize(arg)) return converterr( "string without null bytes or None", arg, msgbuf, bufsize); @@ -1596,7 +1596,7 @@ "keywords must be strings"); return cleanreturn(0, freelist); } - ks = PyString_AsString(key); + ks = PyUnicode_AsString(key); for (i = 0; i < max; i++) { if (!strcmp(ks, kwlist[i])) { match = 1;
