summaryrefslogtreecommitdiffstats
path: root/Doc/api
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2000-09-19 21:04:18 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2000-09-19 21:04:18 (GMT)
commitd1ba443206b535f41154f10b9d56d4fc76a1a9d8 (patch)
treeae56be2777275ca19f347e1154f756ddde4d4b22 /Doc/api
parentf8d071332a485ede280675a55e3319e136826dd0 (diff)
downloadcpython-d1ba443206b535f41154f10b9d56d4fc76a1a9d8.zip
cpython-d1ba443206b535f41154f10b9d56d4fc76a1a9d8.tar.gz
cpython-d1ba443206b535f41154f10b9d56d4fc76a1a9d8.tar.bz2
This patch adds a new Python C API called PyString_AsStringAndSize()
which implements the automatic conversion from Unicode to a string object using the default encoding. The new API is then put to use to have eval() and exec accept Unicode objects as code parameter. This closes bugs #110924 and #113890. As side-effect, the traditional C APIs PyString_Size() and PyString_AsString() will also accept Unicode objects as parameters.
Diffstat (limited to 'Doc/api')
-rw-r--r--Doc/api/api.tex17
-rw-r--r--Doc/api/refcounts.dat5
2 files changed, 22 insertions, 0 deletions
diff --git a/Doc/api/api.tex b/Doc/api/api.tex
index 4362448..9acc8e8 100644
--- a/Doc/api/api.tex
+++ b/Doc/api/api.tex
@@ -2105,6 +2105,23 @@ Macro form of \cfunction{PyString_AsString()} but without error
checking.
\end{cfuncdesc}
+\begin{cfuncdesc}{int}{PyString_AsStringAndSize}{PyObject *obj,
+ char **buffer,
+ int *length}
+Returns a null-terminated representation of the contents of the object
+\var{obj} through the output variables \var{buffer} and \var{length}.
+
+The function accepts both string and Unicode objects as input. For
+Unicode objects it returns the default encoded version of the object.
+If \var{length} is set to \NULL{}, the resulting buffer may not contain
+null characters; if it does, the function returns -1 and a
+TypeError is raised.
+
+The buffer refers to an internal string buffer of \var{obj}, not a
+copy. The data must not be modified in any way. It must not be
+de-allocated.
+\end{cfuncdesc}
+
\begin{cfuncdesc}{void}{PyString_Concat}{PyObject **string,
PyObject *newpart}
Creates a new string object in \var{*string} containing the
diff --git a/Doc/api/refcounts.dat b/Doc/api/refcounts.dat
index 0a80d67..f3ef0ac 100644
--- a/Doc/api/refcounts.dat
+++ b/Doc/api/refcounts.dat
@@ -760,6 +760,11 @@ PyString_AS_STRING:PyObject*:string:0:
PyString_AsString:char*:::
PyString_AsString:PyObject*:string:0:
+PyString_AsStringAndSize:int:::
+PyString_AsStringAndSize:PyObject*:obj:0:
+PyString_AsStringAndSize:char**:buffer::
+PyString_AsStringAndSize:int*:length::
+
PyString_Check:int:::
PyString_Check:PyObject*:o:0: