diff options
author | Guido van Rossum <guido@python.org> | 2000-03-10 23:02:17 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-03-10 23:02:17 (GMT) |
commit | e826ef0a89808da65b24f820feb62b3c49fd369f (patch) | |
tree | 4dc7c86f0b966b3e0f662dba3d3cbbc30ca7110c /Python | |
parent | 5aa88f097f43ae8ebb648f6e1ca57f227a3adc93 (diff) | |
download | cpython-e826ef0a89808da65b24f820feb62b3c49fd369f.zip cpython-e826ef0a89808da65b24f820feb62b3c49fd369f.tar.gz cpython-e826ef0a89808da65b24f820feb62b3c49fd369f.tar.bz2 |
Marc-Andre Lemburg: support for Unicode strings; 'U' expects a Unicode
object.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/getargs.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 2d9e2b7..4617d05 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -585,7 +585,13 @@ convertsimple1(arg, p_format, p_va) char **p = va_arg(*p_va, char **); if (PyString_Check(arg)) - *p = PyString_AsString(arg); + *p = PyString_AS_STRING(arg); + else if (PyUnicode_Check(arg)) { + arg = PyUnicode_AsUTF8String(arg); + if (arg == NULL) + return "unicode conversion error"; + *p = PyString_AS_STRING(arg); + } else return "string"; if ((int)strlen(*p) != PyString_Size(arg)) @@ -625,6 +631,12 @@ convertsimple1(arg, p_format, p_va) *p = 0; else if (PyString_Check(arg)) *p = PyString_AsString(arg); + else if (PyUnicode_Check(arg)) { + arg = PyUnicode_AsUTF8String(arg); + if (arg == NULL) + return "unicode conversion error"; + *p = PyString_AS_STRING(arg); + } else return "None or string"; if (*format == '#') { @@ -652,6 +664,16 @@ convertsimple1(arg, p_format, p_va) break; } + case 'U': /* Unicode object */ + { + PyObject **p = va_arg(*p_va, PyObject **); + if (PyUnicode_Check(arg)) + *p = arg; + else + return "unicode"; + break; + } + case 'O': /* object */ { PyTypeObject *type; |