-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. Also had Dave Malcolm review and tested on python, python3 and python3.2 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk45tFEACgkQrlYvE4MpobPq0QCdEj1A7G6Gt4GKxlPiFXf7GhWS WzsAoNjJ74HK3UBpzcwNDkzMcMR93mD9 =ivUI -----END PGP SIGNATURE-----
>From 79613e83432171b368e212a13536a0af98dc4cd3 Mon Sep 17 00:00:00 2001 From: Eric Paris <eparis@xxxxxxxxxx> Date: Tue, 28 Jun 2011 22:39:40 -0400 Subject: [PATCH 007/155] libselinux: support new python3 functions python3 does not have PyString_FromString use PyBytes_FromString instead. The same for PyString_Check->PyBytes_Check and for PyString_AsString->PyBytes_AsString Signed-off-by: Eric Paris <eparis@xxxxxxxxxx> --- libselinux/src/selinuxswig_python.i | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i index dea0e80..faf7ac5 100644 --- a/libselinux/src/selinuxswig_python.i +++ b/libselinux/src/selinuxswig_python.i @@ -45,7 +45,7 @@ def install(src, dest): PyObject* list = PyList_New(*$2); int i; for (i = 0; i < *$2; i++) { - PyList_SetItem(list, i, PyString_FromString((*$1)[i])); + PyList_SetItem(list, i, PyBytes_FromString((*$1)[i])); } $result = SWIG_Python_AppendOutput($result, list); } @@ -74,7 +74,9 @@ def install(src, dest): len++; plist = PyList_New(len); for (i = 0; i < len; i++) { - PyList_SetItem(plist, i, PyString_FromString((*$1)[i])); + PyList_SetItem(plist, i, + PyBytes_FromString((*$1)[i]) + ); } } else { plist = PyList_New(0); @@ -91,7 +93,9 @@ def install(src, dest): if (*$1) { plist = PyList_New(result); for (i = 0; i < result; i++) { - PyList_SetItem(plist, i, PyString_FromString((*$1)[i])); + PyList_SetItem(plist, i, + PyBytes_FromString((*$1)[i]) + ); } } else { plist = PyList_New(0); @@ -144,16 +148,20 @@ def install(src, dest): $1 = (char**) malloc(size + 1); for(i = 0; i < size; i++) { - if (!PyString_Check(PySequence_GetItem($input, i))) { - PyErr_SetString(PyExc_ValueError, "Sequence must contain only strings"); + if (!PyBytes_Check(PySequence_GetItem($input, i))) { + PyErr_SetString(PyExc_ValueError, "Sequence must contain only bytes"); + return NULL; } + } for(i = 0; i < size; i++) { s = PySequence_GetItem($input, i); - $1[i] = (char*) malloc(PyString_Size(s) + 1); - strcpy($1[i], PyString_AsString(s)); + + $1[i] = (char*) malloc(PyBytes_Size(s) + 1); + strcpy($1[i], PyBytes_AsString(s)); + } $1[size] = NULL; } -- 1.7.6
Attachment:
0007-libselinux-support-new-python3-functions.patch.sig
Description: PGP signature