[capi-sig] Checking int type

Vojtěch Rylko vojta.rylko at seznam.cz
Sun May 23 16:40:24 CEST 2010


Hi,

what am I doing wrong?

C code:
--------------
static PyObject *is_prime(PyObject *self, PyObject *value)
{
     if (!PyInt_Check(value)) {
         PyErr_SetString(PyExc_TypeError, "only integers are acceptable");
         return NULL;
     }
--------------

Test (I'm using integer 3):
------------
 >>> primes.is_prime(3)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ValueError: only integers are acceptable
-------------

Thanks



More information about the capi-sig mailing list