summaryrefslogtreecommitdiff
path: root/src/pycrypto_compat.h
diff options
context:
space:
mode:
authorDwayne Litzenberger <dlitz@dlitz.net>2013-07-14 16:17:01 -0700
committerDwayne Litzenberger <dlitz@dlitz.net>2013-07-14 19:14:35 -0700
commitea2cf0afd8ccbaa406b107285648e024bc900b64 (patch)
tree690b33a3e056246b3800ae9dd44ff504da4dace7 /src/pycrypto_compat.h
parent7e09a5fb6c2db866b3fc7e4d27cdbbe3ac795cc8 (diff)
downloadpycrypto-ea2cf0afd8ccbaa406b107285648e024bc900b64.tar.gz
Py3k cleanup: PyModule_AddIntConstant
Diffstat (limited to 'src/pycrypto_compat.h')
-rw-r--r--src/pycrypto_compat.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pycrypto_compat.h b/src/pycrypto_compat.h
index 6234839..ccaf21a 100644
--- a/src/pycrypto_compat.h
+++ b/src/pycrypto_compat.h
@@ -47,6 +47,18 @@
# endif
#endif
+/* Python 2.1 doesn't have PyModule_AddIntConstant */
+#if PYTHON_API_VERSION < 1011
+#define PyModule_AddIntConstant(m,n,v) \
+ do { \
+ PyObject *o=PyInt_FromLong(v); \
+ if (o!=NULL) { \
+ PyObject_SetAttrString((m),(n),o); \
+ Py_DECREF(o); \
+ } \
+ } while(0)
+#endif
+
/*
* Py_CLEAR for Python < 2.4
* See http://docs.python.org/api/countingRefs.html