"print 0.1==0.1" -> TypeError; what did I do?

Fredrik Lundh fredrik at pythonware.com
Tue Dec 4 02:52:58 EST 2001


Maciej Kalisiak wrote:
> I don't know much of the internals of Python, so this isn't giving me
> any hints as to what the problem is.  Can anyone offer any hints of
> what to look at, as far as debugging goes?  What could cause this type
> of behaviour?

does the problem go away if you add this line just
after the call to your extension:

    hasattr(None, "spam")

if that's the case, you've probably forgotten to check
the return status from some internal Py-function.

a quick and somewhat dirty fix could be to add this to
the end of your C function:

    if (PyErr_Occurred())
        return NULL;

    return result;

a better solution is to make sure you check the return value from
every Py-function that can generate an exception.

for more info, see:

    http://python.sourceforge.net/devel-docs/ext/errors.html
    http://python.sourceforge.net/devel-docs/api/exceptions.html

hope this helps!

</F>





More information about the Python-list mailing list