Re: [Python-ideas] AtributeError inside __get__

2016-12-25 Thread Nick Coghlan
On 26 December 2016 at 04:24, Zahari Dim wrote: > Hi, > > The other day I came across a particularly ugly bug. A simplified case > goes like: > > class X: > @property > def y(self): > return self.nonexisting > > hasattr(X(),'y') > > This returns False because

Re: [Python-ideas] (no subject)

2016-12-25 Thread Chris Angelico
On Mon, Dec 26, 2016 at 8:51 AM, Victor Stinner wrote: > Le 24 déc. 2016 8:42 PM, "Neil Girdhar" a écrit : >> Usually, when an exception is hit that will (probably) crash the program, >> no one cares about less than a microsecond of performance. >

Re: [Python-ideas] AtributeError inside __get__

2016-12-25 Thread Chris Angelico
On Mon, Dec 26, 2016 at 8:03 AM, Nick Timkovich wrote: > Are you saying that hasattr returning False was hiding a bug or is a bug? > The former could be annoying to track down, though hasattr(X, 'y') == True. > For the latter, having hasattr return False if an

Re: [Python-ideas] (no subject)

2016-12-25 Thread Victor Stinner
Le 24 déc. 2016 8:42 PM, "Neil Girdhar" a écrit : > Usually, when an exception is hit that will (probably) crash the program, no one cares about less than a microsecond of performance. Just one example. By design, hasattr(obj, name) raises an exception to return False. So

Re: [Python-ideas] AtributeError inside __get__

2016-12-25 Thread Nick Timkovich
Are you saying that hasattr returning False was hiding a bug or is a bug? The former could be annoying to track down, though hasattr(X, 'y') == True. For the latter, having hasattr return False if an AttributeError is raised would allow the property decorator to retain identical functionality if

[Python-ideas] AtributeError inside __get__

2016-12-25 Thread Zahari Dim
Hi, The other day I came across a particularly ugly bug. A simplified case goes like: class X: @property def y(self): return self.nonexisting hasattr(X(),'y') This returns False because hasattr calls the property which in turn raises an AttributeError which is used to determine