mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
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.
This commit is contained in:
parent
f8d071332a
commit
d1ba443206
8 changed files with 127 additions and 20 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue