diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-10-23 12:49:45 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-10-23 12:49:45 +0200 |
| commit | 62ad4f8a9f447d99d539723e9c7ab8f46c7eda56 (patch) | |
| tree | ec0f9736ae2edbd3453bb182f5fa504158e7e322 /python/generic.h | |
| parent | 01a05d8689621df4c9983be315b864142bb8077a (diff) | |
| parent | 2675db362167b75b1c006e7a165890e2b67079ec (diff) | |
| download | python-apt-62ad4f8a9f447d99d539723e9c7ab8f46c7eda56.tar.gz | |
merged from debian experimental
Diffstat (limited to 'python/generic.h')
| -rw-r--r-- | python/generic.h | 4 |
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. |
