py3compat: add strings describing bytes/unicode in both versions
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 28 Feb 2018 02:59:06 +0000 (15:59 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 1 Mar 2018 03:36:15 +0000 (04:36 +0100)
What Python 3 calls "bytes", Python 2 calls "string";
What Python 3 calls "string", Python 2 calls "unicode".

This can cause confusion in e.g. help strings where the precise type
matters. These macros can be used to construct accurate messages for
both versions.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Thu Mar  1 04:36:15 CET 2018 on sn-devel-144

python/py3compat.h

index f54b3912f175f518fed3c7fb94a0521321736570..ce317c65f8e2ddca8c8ddd6f2829e0b523e516c1 100644 (file)
 #define PyStr_AsUTF8 PyUnicode_AsUTF8
 #define PyStr_AsUTF8AndSize PyUnicode_AsUTF8AndSize
 
+/* description of bytes and string objects */
+#define PY_DESC_PY3_BYTES "bytes"
+#define PY_DESC_PY3_STRING "string"
+
 /* Ints */
 
 #define PyInt_Type PyLong_Type
 #define PyBytes_ConcatAndDel PyString_ConcatAndDel
 #define _PyBytes_Resize _PyString_Resize
 
+/* description of bytes and string objects */
+#define PY_DESC_PY3_BYTES "string"
+#define PY_DESC_PY3_STRING "unicode"
+
 /* PyArg_ParseTuple/Py_BuildValue argument */
 
 #define PYARG_BYTES_LEN "s#"