no __len__ attribute in NodeList or the list base?

sndive at gmail.com sndive at gmail.com
Wed Nov 14 22:26:50 EST 2007


i extract class object from an instance of NodeList (minicompat.py)
like so
PyObject *pclass = PyObject_GetAttrString( nodelistinsance,
"__class__");
but
 PyObject_GetAttrString(pclass, "__len__")
returns NULL.

i naively added
        __len__ = _get_length
to NodeList
but that ends up in endless recursion.

to explain that endless loop i have to assume __len__ is defined
in the NodeList base(list that is)
but i don't see __len__ anywhere in listobject.c!!!

this is in cpython 2.4.4

__len__ is required to be present in NodeList per this:
http://www.python.org/dev/doc/maint24/lib/dom-nodelist-objects.html



More information about the Python-list mailing list