[Cython] PyPy3 fixes

Stefan Behnel stefan_ml at behnel.de
Wed Mar 18 15:07:03 CET 2015


Lisandro Dalcin schrieb am 08.03.2015 um 20:25:
> 1) Stefan, I had to push this fix, just to be sure, please double check.
> 
> https://github.com/cython/cython/commit/6bd3f7b9e494d1259082aecfc0366da15fc105ec

Thanks - sorry for the bug.


> 2) PyPy3 defines some legacy (Py2) Py_TPFLAGS_XXX values. Do you like
> the following fix? IOW, I check if the value is #define'd, if not I
> #define it to 0 (zero):
> 
> diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
> index 6477fb2..3ae8a0c 100644
> --- a/Cython/Utility/ModuleSetupCode.c
> +++ b/Cython/Utility/ModuleSetupCode.c
> @@ -59,13 +59,16 @@
>    #define __Pyx_DefaultClassType PyType_Type
>  #endif
> 
> -#if PY_MAJOR_VERSION >= 3
> +#if !defined(Py_TPFLAGS_CHECKTYPES)
>    #define Py_TPFLAGS_CHECKTYPES 0
> +#endif
> +#if !defined(Py_TPFLAGS_HAVE_INDEX)
>    #define Py_TPFLAGS_HAVE_INDEX 0
> +#endif
> +#if !defined(Py_TPFLAGS_HAVE_NEWBUFFER)
>    #define Py_TPFLAGS_HAVE_NEWBUFFER 0
>  #endif
> -
> -#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
> +#if !defined(Py_TPFLAGS_HAVE_FINALIZE)
>    #define Py_TPFLAGS_HAVE_FINALIZE 0
>  #endif

LGTM. I tend to use the shorter "#ifndef" instead of "#if !defined()", though.

Stefan



More information about the cython-devel mailing list