diff options
author | James Henstridge <james@jamesh.id.au> | 2008-05-28 09:00:36 +0800 |
---|---|---|
committer | James Henstridge <james@jamesh.id.au> | 2008-05-28 09:00:36 +0800 |
commit | a39fb19eb9db28205510aff445214b6c8004b7d8 (patch) | |
tree | cebd034b71336e8dfbd2fa14f5e419cb31b8c4f8 /psycopg/python.h | |
parent | 607319331410a21111965727ebea9ac1d9dd8f23 (diff) | |
download | psycopg2-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.h | 23 |
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) */ |