Author: Antonio Cuni <[email protected]>
Branch: py3k
Changeset: r52876:7ac948ad8042
Date: 2012-02-24 18:06 +0100
http://bitbucket.org/pypy/pypy/changeset/7ac948ad8042/
Log: fix the hasattr tests: now random exceptions won't be eaten by
hasattr, only AttributeError is caught
diff --git a/pypy/module/__builtin__/operation.py
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -79,10 +79,14 @@
"""Return whether the object has an attribute with the given name.
(This is done by calling getattr(object, name) and catching exceptions.)"""
w_name = checkattrname(space, w_name)
- if space.findattr(w_object, w_name) is not None:
+ try:
+ space.getattr(w_object, w_name)
+ except OperationError, e:
+ if e.match(space, space.w_AttributeError):
+ return space.w_False
+ raise
+ else:
return space.w_True
- else:
- return space.w_False
def hash(space, w_object):
"""Return a hash value for the object. Two objects which compare as
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit