#3699 UTIL: Use alternative way for detecting PyErr_NewExceptionWithDoc
Closed 6 years ago by jhrozek. Opened 6 years ago by lslebodn.
SSSD/ lslebodn/sssd configure_python  into  master

file modified
-2
@@ -329,7 +329,6 @@ 

      AM_PYTHON_CONFIG([python2])

      AM_CHECK_PYTHON_HEADERS([],

                              AC_MSG_ERROR([Could not find python2 headers]))

-     AM_CHECK_PYTHON_COMPAT

  

      AC_SUBST([py2execdir], [$pyexecdir])

      AC_SUBST([python2dir], [$pythondir])
@@ -356,7 +355,6 @@ 

      AM_PYTHON_CONFIG([python3])

      AM_CHECK_PYTHON_HEADERS([],

                              AC_MSG_ERROR([Could not find python3 headers]))

-     AM_CHECK_PYTHON_COMPAT

  

      AC_SUBST([py3execdir], [$pyexecdir])

      AC_SUBST([python3dir], [$pythondir])

file modified
-17
@@ -39,23 +39,6 @@ 

      CPPFLAGS="$save_CPPFLAGS"

  ])

  

- 

- dnl Checks for a couple of functions we use that may not be defined

- dnl in some older python (< 2.6) versions used e.g. on RHEL6

- AC_DEFUN([AM_CHECK_PYTHON_COMPAT],

- [

-     AC_REQUIRE([AM_CHECK_PYTHON_HEADERS])

-     save_CPPFLAGS="$CPPFLAGS"

-     save_LIBS="$LIBS"

-     CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"

-     LIBS="$LIBS $PYTHON_LIBS"

- 

-     AC_CHECK_FUNCS([PyErr_NewExceptionWithDoc])

- 

-     CPPFLAGS="$save_CPPFLAGS"

-     LIBS="$save_LIBS"

- ])

- 

  dnl Clean variables after detection of python

  AC_DEFUN([SSS_CLEAN_PYTHON_VARIABLES],

  [

file modified
+1 -1
@@ -23,7 +23,7 @@ 

  PyObject *

  sss_exception_with_doc(char *name, char *doc, PyObject *base, PyObject *dict)

  {

- #ifdef HAVE_PYERR_NEWEXCEPTIONWITHDOC

+ #if PY_VERSION_HEX >= 0x02070000

      return PyErr_NewExceptionWithDoc(name, doc, base, dict);

  #else

      int result;

Function PyErr_NewExceptionWithDoc was added in python 2.7.0
and we use fallback implementation for older versions of python.

Previously, we used detection of PyErr_NewExceptionWithDoc at configure
time; but it does not work well in case of python2.6 and python3.x

Resolves:
https://pagure.io/SSSD/sssd/issue/3656

@sbose, I know you preferred detection at configure time[1] but this version was much simpler and more lines are removed then added. And PY_VERSION_HEX is already used in sssd on other place

[1] https://pagure.io/SSSD/sssd/issue/3653#comment-497100

Given the alternative of having two different variables, one for each python version, I agree that checking PY_VERSION_HEX is more straight forward.

I'll wait for the CI blessing before giving my ack.

Pull-Request has been closed by jhrozek

6 years ago