Edgewall Software

Opened 16 years ago

Closed 16 years ago

#191 closed enhancement (fixed)

Misleading error when an AttributeError exception is raised inside a property object

Reported by: michele Owned by: cmlenz
Priority: minor Milestone: 0.5
Component: Expression evaluation Version: 0.4.4
Keywords: Cc:

Description

When you try to access an attribute that uses a property object and an AttributeError? happens inside the getter method Genshi raises an UndefinedError? exception claiming that the object has not such attribute thus hiding the real exception.

This can be quite confusing (at first I thought Genshi didn't support python properties), it turns out this is not Genshi fault but a well know python issue/non-issue [1].

The patch I'm attaching uses a double check to prevent such an error, when accessing an attribute we don't let getattr manage the AttributeError? exception itself but we catch it and before trying to lookup the attribute using dictionary access we check if the object "really" has not such an attribute, note that I'm not using dir() but obj.class since properties/descriptors cannot be defined per instance but only at class level so this should be enough.

[1] http://mail.python.org/pipermail/python-dev/2005-December/058498.html

Attachments (1)

property_attributeerror.patch (1.7 KB) - added by michele 16 years ago.
the patch

Download all attachments as: .zip

Change History (2)

Changed 16 years ago by michele

the patch

comment:1 Changed 16 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from new to closed

Applied in [818]. Many thanks!

Note: See TracTickets for help on using tickets.