diff options
author | Lumir Balhar <lbalhar@redhat.com> | 2017-10-13 15:36:15 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2017-10-18 09:17:13 +0200 |
commit | 3b5417be2f79a0d4bc9bf3c974ffd12219cb60b8 (patch) | |
tree | 0821ca2400ca3668141d6e5069516c4c4486301d | |
parent | 7d45bbb5c308e322901e90642b4dcf0a4bee200f (diff) | |
download | pam_wrapper-3b5417be2f79a0d4bc9bf3c974ffd12219cb60b8.tar.gz pam_wrapper-3b5417be2f79a0d4bc9bf3c974ffd12219cb60b8.tar.xz pam_wrapper-3b5417be2f79a0d4bc9bf3c974ffd12219cb60b8.zip |
pypamtest: Fix Python 2.6 compatibility
PyErr_NewExceptionWithDoc() isn't available in Python 2.6 so it can
be used only in higher versions of Python.
Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
-rw-r--r-- | src/python/pypamtest.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/python/pypamtest.c b/src/python/pypamtest.c index 585f27d..a71fd35 100644 --- a/src/python/pypamtest.c +++ b/src/python/pypamtest.c @@ -1004,12 +1004,14 @@ static struct PyModuleDef pypamtestdef = { *** Initialize the module **********************************************************/ +#if PY_VERSION_HEX >= 0x02070000 /* >= 2.7.0 */ PyDoc_STRVAR(PamTestError__doc__, "pypamtest specific exception\n\n" "This exception is raised if the _pamtest() function fails. If _pamtest() " "returns PAMTEST_ERR_CASE (a test case returns unexpected error code), then " "the exception also details which test case failed." ); +#endif #if IS_PYTHON3 PyMODINIT_FUNC PyInit_pypamtest(void) @@ -1034,10 +1036,17 @@ PyMODINIT_FUNC initpypamtest(void) pypamtest_module_methods); #endif +#if PY_VERSION_HEX >= 0x02070000 /* >= 2.7.0 */ PyExc_PamTestError = PyErr_NewExceptionWithDoc(discard_const_p(char, "pypamtest.PamTestError"), PamTestError__doc__, PyExc_EnvironmentError, NULL); +#else /* < 2.7.0 */ + PyExc_PamTestError = PyErr_NewException(discard_const_p(char, "pypamtest.PamTestError"), + PyExc_EnvironmentError, + NULL); +#endif + if (PyExc_PamTestError == NULL) { RETURN_ON_ERROR; } |