From: Jason Zaman <jason@perfinion.com>
To: selinux@tycho.nsa.gov
Subject: [PATCH 05/12] sepolicy: C Module init for python3
Date: Fri, 5 Aug 2016 02:33:58 +0800 [thread overview]
Message-ID: <1470335645-24224-6-git-send-email-jason@perfinion.com> (raw)
In-Reply-To: <1470335645-24224-1-git-send-email-jason@perfinion.com>
---
policycoreutils/sepolicy/policy.c | 29 ++++++++++++++++++++++++---
policycoreutils/sepolicy/sepolicy/__init__.py | 2 +-
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/policycoreutils/sepolicy/policy.c b/policycoreutils/sepolicy/policy.c
index b7e3536..423a926 100644
--- a/policycoreutils/sepolicy/policy.c
+++ b/policycoreutils/sepolicy/policy.c
@@ -86,8 +86,31 @@ static PyMethodDef methods[] = {
{NULL, NULL, 0, NULL} /* sentinel */
};
+#if PY_MAJOR_VERSION >= 3
+
+static struct PyModuleDef module_def =
+{
+ PyModuleDef_HEAD_INIT,
+ "_policy", /* name of module */
+ "", /* module documentation, may be NULL */
+ -1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */
+ (PyMethodDef*)&methods,
+};
+
+PyMODINIT_FUNC PyInit__policy(void)
+{
+ PyObject *m;
+ m = PyModule_Create(&module_def);
+ init_info(m);
+ return m;
+}
+
+#else // python 2
+
void init_policy(void) {
-PyObject *m;
-m = Py_InitModule("_policy", methods);
-init_info(m);
+ PyObject *m;
+ m = Py_InitModule("_policy", methods);
+ init_info(m);
}
+
+#endif
diff --git a/policycoreutils/sepolicy/sepolicy/__init__.py b/policycoreutils/sepolicy/sepolicy/__init__.py
index 693c6fe..7804b5c 100644
--- a/policycoreutils/sepolicy/sepolicy/__init__.py
+++ b/policycoreutils/sepolicy/sepolicy/__init__.py
@@ -3,7 +3,7 @@
# Author: Dan Walsh <dwalsh@redhat.com>
# Author: Ryan Hallisey <rhallise@redhat.com>
-import _policy
+from . import _policy
import selinux
import glob
PROGNAME = "policycoreutils"
--
2.7.3
next prev parent reply other threads:[~2016-08-04 18:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-04 18:33 Python3 support in policycoreutils Jason Zaman
2016-08-04 18:33 ` [PATCH 01/12] semanage: py3 support for print function and map/filter Jason Zaman
2016-08-04 18:33 ` [PATCH 02/12] seobject: use sorted() instead of .sort() Jason Zaman
2016-08-04 18:33 ` [PATCH 03/12] semanage: misc style issues Jason Zaman
2016-08-04 18:33 ` [PATCH 04/12] sepolicy: Add python3 PyInt and PyString defs Jason Zaman
2016-08-04 18:33 ` Jason Zaman [this message]
2016-08-04 18:33 ` [PATCH 06/12] sepolicy: update exceptions and print for python3 Jason Zaman
2016-08-04 18:34 ` [PATCH 07/12] sepolicy: dont alias sepolicy.search and sepolicy.info Jason Zaman
2016-08-04 18:34 ` [PATCH 08/12] policycoreutils: import sepolicy directly Jason Zaman
2016-08-18 16:21 ` Stephen Smalley
2016-08-04 18:34 ` [PATCH 09/12] policycoreutils: gettext compat for py2 and 3 Jason Zaman
2016-08-05 8:47 ` Dominick Grift
2016-08-04 18:34 ` [PATCH 10/12] policycoreutils/gui: update to python3 Jason Zaman
2016-08-04 18:34 ` [PATCH 11/12] policycoreutils/gui: py3 support for modules that changed name Jason Zaman
2016-08-04 18:34 ` [PATCH 12/12] semanage: Print usage when no args Jason Zaman
2016-08-08 19:59 ` Python3 support in policycoreutils James Carter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470335645-24224-6-git-send-email-jason@perfinion.com \
--to=jason@perfinion.com \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.