Actually, the object class is defined as:
   class __object(object):
       def __getitem__(self, idx):
           return getattr(self, idx)

Anyway, now I check like this:

bool PyIsSequenceType(PyObject *obj)
{
 if (!PySequence_Check(obj))
   return false;
 Py_ssize_t sz = PySequence_Size(obj);
 if (sz == -1 || PyErr_Occurred() != NULL)
 {
   PyErr_Clear();
   return false;
 }
 return true;
}

I don't like it, any other suggestions?

--
Elias
"lallous" <lall...@lgwm.org> wrote in message news:hdr80a$vs...@aioe.org...
Hello

I have an a class defined as:

   class __object(object):
       pass

Now, I call a C function that takes a PyObject* and checks its type:

if (PyString_Check(obj)) ...
if (PySequence_Check(obj)) ....

Before doing the check, I print the passed object with PyObject_Str() and get:

passed object: <__main__.__object object at 0x040E4050>

However, the C code returns true on the:
if (PySequence_Check(obj)) ....


Why? That is not a sequence?


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to