summaryrefslogtreecommitdiff
path: root/psycopg/python.h
diff options
context:
space:
mode:
authorJames Henstridge <james@jamesh.id.au>2008-05-28 09:00:36 +0800
committerJames Henstridge <james@jamesh.id.au>2008-05-28 09:00:36 +0800
commita39fb19eb9db28205510aff445214b6c8004b7d8 (patch)
treecebd034b71336e8dfbd2fa14f5e419cb31b8c4f8 /psycopg/python.h
parent607319331410a21111965727ebea9ac1d9dd8f23 (diff)
downloadpsycopg2-a39fb19eb9db28205510aff445214b6c8004b7d8.tar.gz
* psycopg/connection_type.c:
* psycopg/cursor_type.c: add support for cyclic GC. * psycopg/python.h: add definitions for Py_CLEAR() and Py_VISIT() for compatibility with old versions of Python.
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) */