This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Strange behavior when AttributeError raise inside a property get function
Type: behavior Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Yariv, ced, ncoghlan, r.david.murray
Priority: normal Keywords:

Created on 2012-07-23 16:26 by ced, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py ced, 2012-07-23 16:26 test.py
Messages (5)
msg166234 - (view) Author: Cédric Krier (ced) * Date: 2012-07-23 16:26
When a AttributeError is raised inside the get function of a property and if the class has a __getattr__ method defined then this method is called.
It is strange behavior because when looking at the traceback it looks like Python doesn't find the property.
msg166241 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-07-23 17:51
AttributeError is how Python decides that __getattr__ should be called.  I believe this is working as designed.
msg166268 - (view) Author: Cédric Krier (ced) * Date: 2012-07-24 09:45
The problem is that the code of the property could raise an AttributeError. So this error is not showed by the traceback.
msg166269 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-07-24 10:04
Yup. It's unfortunate, but there's really nothing we can do about it - some protocols use exceptions, and if you raise an exception type that is part of the defined protocol as the result of a genuine error, then you're going to have a fun debugging exercise to deal with.

You'll often see a similar misdiagnosis with TypeError in conversion functions that try several different conversion techniques.
msg182302 - (view) Author: Yariv (Yariv) Date: 2013-02-18 07:52
Duplicate of http://bugs.python.org/issue1615 , which is open.
History
Date User Action Args
2022-04-11 14:57:33adminsetgithub: 59640
2013-02-18 07:52:37Yarivsetnosy: + Yariv
messages: + msg182302
2012-07-24 10:05:00ncoghlansetstatus: open -> closed

nosy: + ncoghlan
messages: + msg166269

resolution: wont fix
2012-07-24 09:45:18cedsetmessages: + msg166268
2012-07-23 17:51:43r.david.murraysetnosy: + r.david.murray
messages: + msg166241
2012-07-23 16:26:52cedcreate