Not a big deal. I did it this way: // PyPy introduced the PyDateTime_DELTA_* API as functions even though // they aren't available in CPython until v3.x. To make matters // slightly worse, in CPython 3.x they are defined as macros. #if !defined(PYPY_VERSION) && PY_MAJOR_VERSION < 3 #define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)o)->days) #define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)o)-seconds) #define PyDateTime_DELTA_GET_MICROSECONDS(o) (((PyDateTime_Delta*)o)-microseconds) #endif
(Apologies for the bad line wrappage. I am beginning to rue the day I moved to Gmail for all my mail...) Skip On Sat, Sep 7, 2013 at 5:19 AM, Amaury Forgeot d'Arc <amaur...@gmail.com> wrote: > > 2013/9/7 Skip Montanaro <s...@pobox.com> >> >> On Fri, Sep 6, 2013 at 6:13 PM, Skip Montanaro <s...@pobox.com> wrote: >> >> Not sure I understand. Or did you mean "why are those declarations not >> >> in >> >> datetime.h"? >> > >> > Yes, sorry about the typo. >> >> Alas, I am still confused. The PyDateTime_DELTA_GET_* macros aren't >> defined for CPython until the 3.x series. (There are macros in 2.7, >> but they are defined in datetimemodule.c, not in a public header file. >> PyPy declares them as functions. >> >> Is there some predefined "This is PyPy" macro I can check? > > > Now I feel embarrassed. > I was the one who added these macros to CPython 3.3, exactly for this > reason. > see the patch we propose for cx_Oracle: > https://bitbucket.org/pypy/pypy/src/tip/pypy/module/cpyext/patches/cx_Oracle.patch > "#ifdef PyDateTime_DELTA_GET_DAYS" should do the trick for any version. > > > -- > Amaury Forgeot d'Arc _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev