diff options
author | Thorsten Behrens <sbehrens@gmx.li> | 2010-12-28 16:26:52 -0500 |
---|---|---|
committer | Thorsten Behrens <sbehrens@gmx.li> | 2010-12-28 16:26:52 -0500 |
commit | 295ce314d9f5c750d9569ac75a4f78331fae9992 (patch) | |
tree | 943c5f2e5237b3cf0665dd8fed278e4efa518770 /src/pycrypto_compat.h | |
parent | 1873473e13161587b870adadc70c1d625f8bc5cf (diff) | |
download | pycrypto-295ce314d9f5c750d9569ac75a4f78331fae9992.tar.gz |
Changes to allow pycrpyto to work on Python 3.x as well as 2.1 through 2.7
Diffstat (limited to 'src/pycrypto_compat.h')
-rw-r--r-- | src/pycrypto_compat.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/pycrypto_compat.h b/src/pycrypto_compat.h index c40d4b5..eaaebdb 100644 --- a/src/pycrypto_compat.h +++ b/src/pycrypto_compat.h @@ -23,6 +23,26 @@ */ #ifndef PYCRYPTO_COMPAT_H #define PYCRYPTO_COMPAT_H +#include "Python.h" + +/* + * Python 3.x defines, for conditional compiles + */ + +#if PY_MAJOR_VERSION >= 3 +#define IS_PY3K +#else +#define PyBytes_GET_SIZE PyString_GET_SIZE +#define PyBytes_FromStringAndSize PyString_FromStringAndSize +#define PyBytes_AS_STRING PyString_AS_STRING +#define PyBytes_Check PyString_Check +#define PyBytes_Size PyString_Size +#define PyBytes_AsString PyString_AsString +#define PyBytesObject PyStringObject +#if PY_MINOR_VERSION <= 5 /* PyUnicode_FromString exists from Python 2.6 on up */ +#define PyUnicode_FromString PyString_FromString +#endif +#endif /* * Py_CLEAR for Python < 2.4 |