diff options
author | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2008-08-16 20:14:04 -0400 |
---|---|---|
committer | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2008-09-21 00:53:13 -0400 |
commit | 568ae1ad9a81e44b4f014f5a940c78bb5aaef661 (patch) | |
tree | c4657d618555edf1d4b8339bef1ab0d1042bd3b8 /src/pycrypto_compat.h | |
parent | db9223b18b0c00854cccd1725688b75a013453dd (diff) | |
download | pycrypto-568ae1ad9a81e44b4f014f5a940c78bb5aaef661.tar.gz |
Add Py_CLEAR macro to pycrypto_compat.h
Diffstat (limited to 'src/pycrypto_compat.h')
-rw-r--r-- | src/pycrypto_compat.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pycrypto_compat.h b/src/pycrypto_compat.h index 884ddc6..352f4be 100644 --- a/src/pycrypto_compat.h +++ b/src/pycrypto_compat.h @@ -28,6 +28,19 @@ #define PYCRYPTO_COMPAT_H /* + * Py_CLEAR for Python < 2.4 + * See http://docs.python.org/api/countingRefs.html + */ +#if PY_VERSION_HEX < 0x02040000 && !defined(Py_CLEAR) +#define Py_CLEAR(obj) \ + do {\ + PyObject *tmp = (PyObject *)(obj);\ + (obj) = NULL;\ + Py_XDECREF(tmp);\ + } while(0) +#endif + +/* * Compatibility code for Python < 2.5 (see PEP 353) * PEP 353 has been placed into the public domain, so we can use this code * without restriction. |