5
  +   ˆl–Ým_JJ_)ÕÁ=p©‹Fÿ¿„m¶ÿ_†I|¥�+ÃÂ <Ç    #ifndef HAS_ETREE_DEFS_H
#define HAS_ETREE_DEFS_H

/* quick check for Python/libxml2/libxslt devel setup */
#include "Python.h"
#ifndef PY_VERSION_HEX
#  error the development package of Python (header files etc.) is not installed correctly
#else
#  if PY_VERSION_HEX < 0x02070000 || PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x03050000
#  error this version of lxml requires Python 2.7, 3.5 or later
#  endif
#endif

#include "libxml/xmlversion.h"
#ifndef LIBXML_VERSION
#  error the development package of libxml2 (header files etc.) is not installed correctly
#else
#if LIBXML_VERSION < 20700
#  error minimum required version of libxml2 is 2.7.0
#endif
#endif

#include "libxslt/xsltconfig.h"
#ifndef LIBXSLT_VERSION
#  error the development package of libxslt (header files etc.) is not installed correctly
#else
#if LIBXSLT_VERSION < 10123
#  error minimum required version of libxslt is 1.1.23
#endif
#endif


/* v_arg functions */
#define va_int(ap)     va_arg(ap, int)
#define va_charptr(ap) va_arg(ap, char *)

#ifdef PYPY_VERSION
#    define IS_PYPY 1
#else
#    define IS_PYPY 0
#endif

#if PY_MAJOR_VERSION >= 3
#  define IS_PYTHON2 0  /* prefer for special casing Python 2.x */
#  define IS_PYTHON3 1  /* avoid */
#else
#  define IS_PYTHON2 1
#  define IS_PYTHON3 0
#endif

#if IS_PYTHON2
#ifndef LXML_UNICODE_STRINGS
#define LXML_UNICODE_STRINGS 0
#endif
#else
#undef LXML_UNICODE_STRINGS
#define LXML_UNICODE_STRINGS 1
#endif

#if !IS_PYPY
#  define PyWeakref_LockObject(obj)          (NULL)
#endif

/* Threading is not currently supported by PyPy */
#if IS_PYPY
#  ifndef WITHOUT_THREADING
#    define WITHOUT_THREADING
#  endif
#endif

#if IS_PYPY
#  undef PyFile_AsFile
#  define PyFile_AsFile(o)                   (NULL)
#  undef PyByteArray_Check
#  define PyByteArray_Check(o)               (0)
#elif !IS_PYTHON2
   /* Python 3+ doesn't have PyFile_*() anymore */
#  define PyFile_AsFile(o)                   (NULL)
#endif

#if PY_VERSION_HEX <= 0x03030000 && !(defined(CYTHON_PEP393_ENABLED) && CYTHON_PEP393_ENABLED)
  #define PyUnicode_IS_READY(op)    (0)
  #define PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
#endif

#if IS_PYPY
#  ifndef PyUnicode_FromFormat
#    define PyUnicode_FromFormat  PyString_FromFormat
#  endif
#  if !IS_PYTHON2 && !defined(PyBytes_FromFormat)
#    ifdef PyString_FromFormat
#      define PyBytes_FromFormat  PyString_FromFormat
#    else
#include <stdarg.h>
static PyObject* PyBytes_FromFormat(const char* format, ...) {
    PyObject *string;
    va_list vargs;
#ifdef HAVE_STDARG_PROTOTYPES
    va_start(vargs, format);
#else
    va_start(vargs);
#endif
    string = PyUnicode_FromFormatV(format, vargs);
    va_end(vargs);
    if (string && PyUnicode_Check(string)) {
        PyObject *bstring = PyUnicode_AsUTF8String(string);
        Py_DECREF(string);
        string = bstring;
    }
    if (string && !PyBytes_CheckExact(string)) {
        Py_DECREF(string);
        string = NULL;
        PyErr_SetString(PyExc_TypeError, "String formatting and encoding failed to return bytes object");
    }
    return string;
}
#    endif
#  endif
#endif

/* PySlice_GetIndicesEx() has wrong signature in Py<=3.1 */
#if PY_VERSION_HEX >= 0x03020000
#  define _lx_PySlice_GetIndicesEx(o, l, b, e, s, sl) PySlice_GetIndicesEx(o, l, b, e, s, sl)
#else
#  define _lx_PySlice_GetIndicesEx(o, l, b, e, s, sl) PySlice_GetIndicesEx(((PySliceObject*)o), l, b, e, s, sl)
#endif

#ifdef WITHOUT_THREADING
#  undef PyEval_SaveThread
#  define PyEval_SaveThread() (NULL)
#  undef PyEval_RestoreThread
#  define PyEval_RestoreThread(state)  if (state); else {}
#  undef PyGILState_Ensure
#  define PyGILState_Ensure() (PyGILState_UNLOCKED)
#  undef PyGILState_Release
#  define PyGILState_Release(state)  if (state); else {}
#  undef  Py_UNBLOCK_THREADS
#  define Py_UNBLOCK_THREADS  _save = NULL;
#  undef  Py_BLOCK_THREADS
#  define Py_BLOCK_THREADS  if (_save); els