[Python-Dev] Exception __name__ missing?

Scott Dial scott+python-dev at scottdial.com
Mon Jan 17 22:09:47 CET 2011


On 1/17/2011 3:22 PM, Ron Adam wrote:
> Is this on purpose?

This reminds me of something I ran into a few years ago wrt. the
attribute on exceptions. Namely, that instances of built-in exceptions
do not have a __module__ attribute, but instance of user exceptions do
-- a change which appeared in Python 2.5:

http://mail.python.org/pipermail/python-list/2007-November/1088229.html

I had a use case, using ZSI to provide a SOAP interface, where being
able to get the __module__ and __name__ was needed (to serialize into a
SOAP "fault" message).

I worked around the issue by referencing the __class__ (as the other
replier mentioned). But, I didn't receive any responses then, so I think
not a lot of attention was put into these type of attributes on exceptions.

-- 
Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu


More information about the Python-Dev mailing list