From 01e89ada251eb8bf0556568604298d56d9b41043 Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Wed, 11 Oct 2017 21:00:29 +0200 Subject: [PATCH] python: 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 Reviewed-by: Andrew Bartlet Reviewed-by: Andreas Schneider --- lib/pam_wrapper/python/pypamtest.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/pam_wrapper/python/pypamtest.c b/lib/pam_wrapper/python/pypamtest.c index 585f27d0f11..a71fd359bff 100644 --- a/lib/pam_wrapper/python/pypamtest.c +++ b/lib/pam_wrapper/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; } -- 2.11.4.GIT