1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

python: Add new compat PYARG_STR_UNI format

In python2 PYARG_STR_UNI evaluates to et which allows str type
(e.g bytes) pass through unencoded and accepts unicode objects
encoded as utf8
In python3 PYARG_STR_UNI evaluates to es which allows str type
encoded as named/specified encoding

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Noel Power 2018-12-11 15:18:10 +00:00 committed by Douglas Bagnall
parent 5232979de8
commit 253af8b854

View File

@ -118,6 +118,7 @@
/* PyArg_ParseTuple/Py_BuildValue argument */
#define PYARG_BYTES_LEN "y#"
#define PYARG_STR_UNI "es"
#else
@ -179,6 +180,15 @@
/* PyArg_ParseTuple/Py_BuildValue argument */
#define PYARG_BYTES_LEN "s#"
/*
* We want a format that will ensure unicode is encoded using the
* specified encoding 'utf8' (to obtain the char* array)
* In python3 we use "es" but in python2 the specifiying 'es' will
* result in the any incomming 'str' type being decoded first to ascii
* then encoded to the specified 'utf8' encoding. In order to avoid that
* we use format 'et' in python2 instead.
*/
#define PYARG_STR_UNI "et"
/* Module init */