1 /***************************************************************************** 2 3 Copyright (c) 2012 Zope Foundation and Contributors. 4 All Rights Reserved. 5 6 This software is subject to the provisions of the Zope Public License, 7 Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. 8 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED 9 WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 10 WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS 11 FOR A PARTICULAR PURPOSE 12 13 ****************************************************************************/ 14 15 #ifndef PERSISTENT__COMPAT_H 16 #define PERSISTENT__COMPAT_H 17 18 #include "Python.h" 19 20 #if PY_MAJOR_VERSION >= 3 21 #define PY3K 22 #endif 23 24 #ifdef PY3K 25 #define INTERN PyUnicode_InternFromString 26 #define INTERN_INPLACE PyUnicode_InternInPlace 27 #define NATIVE_CHECK_EXACT PyUnicode_CheckExact 28 #define NATIVE_FROM_STRING_AND_SIZE PyUnicode_FromStringAndSize 29 30 #define Py_TPFLAGS_HAVE_RICHCOMPARE 0 31 32 #define INT_FROM_LONG(x) PyLong_FromLong(x) 33 #define INT_CHECK(x) PyLong_Check(x) 34 #define INT_AS_LONG(x) PyLong_AsLong(x) 35 #define CAPI_CAPSULE_NAME "persistent.cPersistence.CAPI" 36 37 #else 38 #define INTERN PyString_InternFromString 39 #define INTERN_INPLACE PyString_InternInPlace 40 #define NATIVE_CHECK_EXACT PyString_CheckExact 41 #define NATIVE_FROM_STRING_AND_SIZE PyString_FromStringAndSize 42 43 #define INT_FROM_LONG(x) PyInt_FromLong(x) 44 #define INT_CHECK(x) PyInt_Check(x) 45 #define INT_AS_LONG(x) PyInt_AS_LONG(x) 46 #endif 47 48 #endif 49