[Python-Dev] Attribute error: providing type name

Guilherme Polo ggpolo at gmail.com
Sun Nov 30 20:58:59 CET 2008


On Sun, Nov 30, 2008 at 4:41 PM, Filip Gruszczyński <gruszczy at gmail.com> wrote:
> This is my first message in this list, therefore I would like to say
> hello to everyone. I also hope, that I am not breaking any rules or
> guidelines for sending proposals.
>
> I would like to ask, if it is possible to provide type name of the
> object invoking the exception, when Attribute error is catched. It is
> done for functions, like:
>
> AttributeError: 'function' object has no attribute 'getValue'
>
> but for some objects there is only:
>
> AttributeError: connectToBases

I would say this is due to Py_FindMethod being used.
It is a nice and easy function to use, but it fails to set a good
error message so maybe you are experiencing these error messages from
modules that are using it.

I have added a patch in http://bugs.python.org/issue4475

>
> This is cool, when you know exactly what type of object cast the
> exception. But if there might be many of them, you must do one of two
> things: add print statement just before the line with the exception
> and check the type or iterate over all classes that might appear them.
> Showing the class name would solve this problem and could save a lot
> of time.
>
> --
> Filip Gruszczyński
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/ggpolo%40gmail.com
>



-- 
-- Guilherme H. Polo Goncalves


More information about the Python-Dev mailing list