summaryrefslogtreecommitdiff
path: root/python/generic.h
diff options
context:
space:
mode:
authorMichael Vogt <egon@debian-devbox>2013-05-08 19:09:21 +0200
committerMichael Vogt <egon@debian-devbox>2013-05-08 19:09:21 +0200
commite2e4d3dd3dc2a41469f5d559cbdb5ca6c5057f01 (patch)
tree6c3655648f24418b207422ff3125632bebf53962 /python/generic.h
parent7cf77010c108df676d3e277716f790b994bba28e (diff)
parentb805a16a7466a99bf0952b0ccc0dc7c5b3c6f797 (diff)
downloadpython-apt-e2e4d3dd3dc2a41469f5d559cbdb5ca6c5057f01.tar.gz
merged from experimental and uploaded to sid
Diffstat (limited to 'python/generic.h')
-rw-r--r--python/generic.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/python/generic.h b/python/generic.h
index f9680ca5..914456e2 100644
--- a/python/generic.h
+++ b/python/generic.h
@@ -80,10 +80,14 @@ typedef int Py_ssize_t;
static inline const char *PyUnicode_AsString(PyObject *op) {
// Convert to bytes object, using the default encoding.
+#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3
+ return PyUnicode_AsUTF8(op);
+#else
// Use Python-internal API, there is no other way to do this
// without a memory leak.
PyObject *bytes = _PyUnicode_AsDefaultEncodedString(op, 0);
return bytes ? PyBytes_AS_STRING(bytes) : 0;
+#endif
}
// Convert any type of string based object to a const char.