summaryrefslogtreecommitdiff
path: root/psycopg/python.h
diff options
context:
space:
mode:
Diffstat (limited to 'psycopg/python.h')
-rw-r--r--psycopg/python.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/psycopg/python.h b/psycopg/python.h
index 84bacaa..13d6ce7 100644
--- a/psycopg/python.h
+++ b/psycopg/python.h
@@ -41,4 +41,27 @@
#define freefunc destructor
#endif
+/* Py_VISIT and Py_CLEAR introduced in Python 2.4 */
+#ifndef Py_VISIT
+#define Py_VISIT(op) \
+ do { \
+ if (op) { \
+ int vret = visit((op), arg); \
+ if (vret) \
+ return vret; \
+ } \
+ } while (0)
+#endif
+
+#ifndef Py_CLEAR
+#define Py_CLEAR(op) \
+ do { \
+ if (op) { \
+ PyObject *tmp = (PyObject *)(op); \
+ (op) = NULL; \
+ Py_DECREF(tmp); \
+ } \
+ } while (0)
+#endif
+
#endif /* !defined(PSYCOPG_PYTHON_H) */