summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-10-23 12:49:45 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-10-23 12:49:45 +0200
commit62ad4f8a9f447d99d539723e9c7ab8f46c7eda56 (patch)
treeec0f9736ae2edbd3453bb182f5fa504158e7e322 /python
parent01a05d8689621df4c9983be315b864142bb8077a (diff)
parent2675db362167b75b1c006e7a165890e2b67079ec (diff)
downloadpython-apt-62ad4f8a9f447d99d539723e9c7ab8f46c7eda56.tar.gz
merged from debian experimental
Diffstat (limited to 'python')
-rw-r--r--python/generic.h4
-rw-r--r--python/tag.cc4
2 files changed, 6 insertions, 2 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.
diff --git a/python/tag.cc b/python/tag.cc
index 248d818d..6ae439f5 100644
--- a/python/tag.cc
+++ b/python/tag.cc
@@ -74,7 +74,7 @@ int TagFileClear(PyObject *self) {
PyString_FromStringAndSize((v), (len))
#define TagSecString_FromString(self, v) PyString_FromString(v)
#else
-PyObject *TagSecString_FromStringAndSize(PyObject *self, const char *v,
+static PyObject *TagSecString_FromStringAndSize(PyObject *self, const char *v,
Py_ssize_t len) {
TagSecData *Self = (TagSecData *)self;
if (Self->Bytes)
@@ -85,7 +85,7 @@ PyObject *TagSecString_FromStringAndSize(PyObject *self, const char *v,
return PyUnicode_FromStringAndSize(v, len);
}
-PyObject *TagSecString_FromString(PyObject *self, const char *v) {
+static PyObject *TagSecString_FromString(PyObject *self, const char *v) {
TagSecData *Self = (TagSecData *)self;
if (Self->Bytes)
return PyBytes_FromString(v);