diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-05-04 19:28:21 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-05-04 19:28:21 (GMT) |
commit | 612344f12774cbbefd735d9fcbfb2001fe187362 (patch) | |
tree | 3be6051c7e4ac7fe3a93372fa3d86bce06072e1f /Doc | |
parent | c2b87a6dff1edade6542a484cb9b9419b254c1ed (diff) | |
download | cpython-612344f12774cbbefd735d9fcbfb2001fe187362.zip cpython-612344f12774cbbefd735d9fcbfb2001fe187362.tar.gz cpython-612344f12774cbbefd735d9fcbfb2001fe187362.tar.bz2 |
Change UnicodeDecodeError objects so that the 'object' attribute
is a bytes object.
Add 'y' and 'y#' format specifiers that work like 's' and 's#'
but only accept bytes objects.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/api/utilities.tex | 12 | ||||
-rw-r--r-- | Doc/ext/extending.tex | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Doc/api/utilities.tex b/Doc/api/utilities.tex index 93e3796..fb9c909 100644 --- a/Doc/api/utilities.tex +++ b/Doc/api/utilities.tex @@ -424,6 +424,18 @@ whose address should be passed. compatible objects pass back a reference to the raw internal data representation. + \item[\samp{y} (bytes object) + {[const char *]}] + This variant on \samp{s} convert a Python bytes object to a C pointer to a + character string. The bytes object must not contain embedded NUL bytes; + if it does, a \exception{TypeError} exception is raised. + + \item[\samp{y\#} (bytes object) + {[const char *, int]}] + This variant on \samp{s#} stores into two C variables, the first one + a pointer to a character string, the second one its length. This only + accepts bytes objects. + \item[\samp{z} (string or \code{None}) {[const char *]}] Like \samp{s}, but the Python object may also be \code{None}, in which case the C pointer is set to \NULL. diff --git a/Doc/ext/extending.tex b/Doc/ext/extending.tex index 2af88b5..1f3e2d5 100644 --- a/Doc/ext/extending.tex +++ b/Doc/ext/extending.tex @@ -802,8 +802,10 @@ Examples (to the left the call, to the right the resulting Python value): Py_BuildValue("i", 123) 123 Py_BuildValue("iii", 123, 456, 789) (123, 456, 789) Py_BuildValue("s", "hello") 'hello' + Py_BuildValue("y", "hello") b'hello' Py_BuildValue("ss", "hello", "world") ('hello', 'world') Py_BuildValue("s#", "hello", 4) 'hell' + Py_BuildValue("y#", "hello", 4) b'hell' Py_BuildValue("()") () Py_BuildValue("(i)", 123) (123,) Py_BuildValue("(ii)", 123, 456) (123, 456) |