[pypy-commit] pypy py3k: one more hasattr test which passes with -A but fails on pypy

antocuni noreply at buildbot.pypy.org
Fri Feb 24 20:13:30 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r52875:16ec2588021e
Date: 2012-02-24 16:30 +0100
http://bitbucket.org/pypy/pypy/changeset/16ec2588021e/

Log:	one more hasattr test which passes with -A but fails on pypy

diff --git a/pypy/module/__builtin__/test/test_builtin.py b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -596,6 +596,17 @@
         raises(TypeError, hasattr, x, 42)
         assert hasattr(x, '\u5678') is False
 
+    def test_hasattr_exception(self):
+        class X(object):
+            def __getattr__(self, name):
+                if name == 'foo':
+                    raise AttributeError
+                else:
+                    raise KeyError
+        x = X()
+        assert hasattr(x, 'foo') is False
+        raises(KeyError, "hasattr(x, 'bar')")
+
     def test_compile_leading_newlines(self):
         src = """
 def fn(): pass


More information about the pypy-commit mailing list