diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2007-11-22 02:48:12 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2007-11-22 02:48:12 (GMT) |
commit | 39599dca9db7431510f1d68609db5ea0b60af2cb (patch) | |
tree | e73e57d1e631fe1b6572bea4e915cc604fd88044 /Python/getargs.c | |
parent | 484fcd4521cd63beffeb45bca8396dcd7b377f0a (diff) | |
download | cpython-39599dca9db7431510f1d68609db5ea0b60af2cb.zip cpython-39599dca9db7431510f1d68609db5ea0b60af2cb.tar.gz cpython-39599dca9db7431510f1d68609db5ea0b60af2cb.tar.bz2 |
PyString_AsString is permissive and accepts unicode strings.
Replace it with PyUnicode_AsString when the argument is known to be a str.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r-- | Python/getargs.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 48860cc..584805e 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -768,7 +768,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, 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 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, } 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 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, 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 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format, "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; |