PySequence_SetItem

Fredrik Lundh fredrik at pythonware.com
Thu Aug 17 08:35:11 EDT 2006


John Machin wrote:

> 1. It's also documented as being the recommended way of filling up a
> list after PyList_New.

since it doesn't work in any existing Python release, it's hardly "recommended".

the Python documentation has never been formally binding; if the documentation
doesn't match the code, it's usually the documentation that's flawed.

> 2. So you'd rather not change the code, and just let it segfault if
> someone calls it (or PyObject_SetItem) instead of PyList_SetItem?

as I said, you're using an API that's designed for use on *properly initialized*
objects on an object that *hasn't been initialized*.  if you're going to patch all
places where that can happen, you might as well rewrite the entire interpreter.

the documentation is broken, and *must* be fixed.  catching this specific case
in the code is a lot less important; it's just one of many possible errors you can
make when writing C-level code.  there's simply no way you can catch them
all.

</F> 






More information about the Python-list mailing list