Message3392

Author akruis
Recipients akruis
Date 2008-08-04.10:12:52
SpamBayes Score 2.7079854e-05
Marked as misclassified No
Message-id <1217844773.47.0.122737223077.issue1095@psf.upfronthosting.co.za>
In-reply-to
Content
Sorry, I accidentally hit the Return-key while creating the ticket. 

Here is the description:

Jython catches AttributeErrors (and subclasses thereof) raised by
__getattr__(self, name) and replaces the exception by the default 
AttributeError. CPython does not show this behaviour.

Running the attached test script with the latest 2.5a release of Jython
gives:
> ~/src/jython2.5a1+/jython testAttributeError.py
Caught exception is different from raised exception
    Caught: class <type 'exceptions.AttributeError'> ''instance' object
has no attribute 'xyz''
    Raised: class <class '__main__.DerivedAttributeError'> 'xyz'

On CPython, the output of the attached test script is:
Caught exception is raised exception

This problem is very similar to #1041. "AttributeError raised from
descriptors __get__ method are swallowed"

Why is this difference a problem: 
I'm maintainer of an application, that uses jython as its embedded
scripting language. The API provided for users of this application shall
resemble CPython as much as possible and therefore hides some
implementation details using __getattr__ and similar methods. Errors on
attribute access usually raise an AttributeError and I'd prefer to stay
with that convention. However I need to pass some more information about
the real cause of the exception.
History
Date User Action Args
2008-08-04 10:12:53akruissetmessageid: <1217844773.47.0.122737223077.issue1095@psf.upfronthosting.co.za>
2008-08-04 10:12:53akruissetrecipients: + akruis
2008-08-04 10:12:53akruislinkissue1095 messages
2008-08-04 10:12:53akruiscreate