From 7bd938dd78ab27ec23ffd84811dbdfa5dd83593a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 15 Oct 2012 10:09:01 +0200 Subject: * python/tag.cc: - make TagSecString_FromStringAndSize, TagSecString_FromString static, thanks to jcristau --- python/tag.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python') 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); -- cgit v1.2.3 From 6bd628c370b05b80b59552e4bbc970928aca91a1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 23 Oct 2012 12:37:49 +0200 Subject: build fixes for python3.3 --- apt/auth.py | 3 ++- debian/changelog | 3 ++- python/generic.h | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/apt/auth.py b/apt/auth.py index eff13b1a..c1b8da2a 100644 --- a/apt/auth.py +++ b/apt/auth.py @@ -78,7 +78,8 @@ def _call_apt_key_script(*args, **kwargs): stderr=subprocess.PIPE) content = kwargs.get("stdin", None) - if isinstance(content, unicode): + # py2 needs this encoded, py3.3 will crash if it is + if isinstance(content, unicode) and sys.version_info[:2] < (3, 3): content = content.encode("utf-8") output, stderr = proc.communicate(content) diff --git a/debian/changelog b/debian/changelog index 0e8ca556..5d0b3900 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,7 +7,8 @@ python-apt (0.8.8.1) UNRELEASED; urgency=low * python/cache.cc: - add "Codename" to PackageFile object * add dep8 style autopkgtest support - + * build fixes for python3.3 + [ Jason Conti ] * lp:~jconti/python-apt/closeable-cache: - add apt.Cache.close() method 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. -- cgit v1.2.3