X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/a539ffb8538158c1dc7eeb4ad5264a6e995496b6..2a448f86048c26a24288d310b3bb70e8ae7e7528:/pyke/pyke.h diff --git a/pyke/pyke.h b/pyke/pyke.h index 2934543..e6d465e 100644 --- a/pyke/pyke.h +++ b/pyke/pyke.h @@ -62,6 +62,18 @@ PRIVATE_SYMBOLS; +/*----- Python version compatibility hacks --------------------------------*/ + +/* The handy `Py_TYPE' and `Py_SIZE' macros turned up in 2.6. Define them if + * they're not already here. + */ +#ifndef Py_TYPE +# define Py_TYPE(obj) (((PyObject *)(obj))->ob_type) +#endif +#ifndef Py_SIZE +# define Py_SIZE(obj) (((PyVarObject *)(obj))->ob_size) +#endif + /*----- Utilities for returning values and exceptions ---------------------*/ /* Returning values. */ @@ -153,8 +165,7 @@ extern PyObject *getulong(unsigned long); /* any kind of unsigned integer */ /*----- Miscellaneous utilities -------------------------------------------*/ -#define FREEOBJ(obj) \ - (((PyObject *)(obj))->ob_type->tp_free((PyObject *)(obj))) +#define FREEOBJ(obj) (Py_TYPE(obj)->tp_free((PyObject *)(obj))) /* Actually free OBJ, e.g., in a deallocation function. */ extern PyObject *abstract_pynew(PyTypeObject *, PyObject *, PyObject *);