Add 'U'/'U#' format characters to Py_BuildValue (and thus

to PyObject_CallFunction()) that take a char * (and a size
in the case of 'U#') and create a unicode object out of it.

Add functions PyUnicode_FromFormat() and PyUnicode_FromFormatV()
that work similar to PyString_FromFormat(), but create a unicode
object (also a %U format character has been added, that takes
a PyObject *, which must point to a unicode object).

Change the encoding and reason attributes of UnicodeEncodeError,
UnicodeDecodeError and UnicodeTranslateError to be unicode
objects.
This commit is contained in:
Walter Dörwald 2007-05-18 16:29:38 +00:00
parent 5550731d9c
commit d2034310d6
6 changed files with 376 additions and 113 deletions

View file

@ -848,6 +848,15 @@ PyArg_ParseTuple(args, "O|O:ref", &object, &callback)
to a Python Unicode object. If the Unicode buffer pointer
is \NULL, the length is ignored and \code{None} is returned.
\item[\samp{U} (string) {[char *]}]
Convert a null-terminated C string to a Python unicode object.
If the C string pointer is \NULL, \code{None} is used.
\item[\samp{U\#} (string) {[char *, int]}]
Convert a C string and its length to a Python unicode object.
If the C string pointer is \NULL, the length is ignored and \code{None}
is returned.
\item[\samp{i} (integer) {[int]}]
Convert a plain C \ctype{int} to a Python integer object.