> (since PyInt_* functions don't exist in Python 3.0).

Some PyInt_ functions exist in intobject.h, which you need to include
explicitly.

> But
> since an integer fails "PyLong_Check()" in Python 2.*, how can I check
> for integers portably between Python 2.[3-6] and Python 3.0?. I would
> like to avoid conditional compilation, if possible.

Depends on what you want to test. If anything that has nb_int available
is sufficient, check for presence of nb_int. If you only want to test
for int-or-long, use intobject.h, and write

if (PyInt_Check(o) || PyLong_Check(o))

If you don't want to use intobject.h, write

#ifndef PyInt_Check
#define PyInt_Check(x) PyLong_Check(x)
#endif

at the top, then use the same if block.

HTH,
Martin
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to