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.

Author Jun Wang
Recipients Jun Wang
Date 2015-11-16.09:39:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1447666799.36.0.119700754928.issue25634@psf.upfronthosting.co.za>
In-reply-to
Content
See this simple example:

class A(): 
	def __init__(self, x=None): 
		self.x = x

	@property
	def t(self): 
		return self.x.t

	def __getattr__(self, name): 
		return 'default'

print(A().t)


AttributeError is raised as "'NoneType' object has no attribute 't'". Currently __getattr__ is called if any AttributeError is raised, so the result of a.t is *default*, while an AttributeError is the desired behavior.

The most intuitive solution seems to add a subclass of AttributeError, say AttributeMissError, which triggers __getattr__. At present, I have to do some tricky and ugly things to __getattribute__ to show where the AttributeError occurs, or it's quite hard to figure out what happened with no informative traceback messages.
History
Date User Action Args
2015-11-16 09:39:59Jun Wangsetrecipients: + Jun Wang
2015-11-16 09:39:59Jun Wangsetmessageid: <1447666799.36.0.119700754928.issue25634@psf.upfronthosting.co.za>
2015-11-16 09:39:59Jun Wanglinkissue25634 messages
2015-11-16 09:39:58Jun Wangcreate