summaryrefslogtreecommitdiffstats
path: root/Include/stringobject.h
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 /Include/stringobject.h
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 'Include/stringobject.h')
-rw-r--r--Include/stringobject.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/Include/stringobject.h b/Include/stringobject.h
index 7afd347..3bba7bc 100644
--- a/Include/stringobject.h
+++ b/Include/stringobject.h
@@ -103,6 +103,21 @@ extern DL_IMPORT(PyObject*) PyString_AsEncodedString(
const char *errors /* error handling */
);
+/* Provides access to the internal data buffer and size of a string
+ object or the default encoded version of an Unicode object. Passing
+ NULL as *len parameter will force the string buffer to be
+ 0-terminated (passing a string with embedded NULL characters will
+ cause an exception). */
+
+extern DL_IMPORT(int) PyString_AsStringAndSize(
+ register PyObject *obj, /* string or Unicode object */
+ register char **s, /* pointer to buffer variable */
+ register int *len /* pointer to length variable or NULL
+ (only possible for 0-terminated
+ strings) */
+ );
+
+
#ifdef __cplusplus
}
#endif