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
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 it
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 it has the cost of buil
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 AttributeError is raised
> would allo
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.
>
> Just one example. By design, hasattr(obj, name)
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 hasattr calls the pro