[pypy-svn] r40155 - in pypy/dist/pypy/objspace: . test

arigo at codespeak.net arigo at codespeak.net
Sat Mar 10 11:38:27 CET 2007


Author: arigo
Date: Sat Mar 10 11:38:26 2007
New Revision: 40155

Modified:
   pypy/dist/pypy/objspace/descroperation.py
   pypy/dist/pypy/objspace/test/test_descroperation.py
Log:
Test and fix for a segfault.


Modified: pypy/dist/pypy/objspace/descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/descroperation.py	(original)
+++ pypy/dist/pypy/objspace/descroperation.py	Sat Mar 10 11:38:26 2007
@@ -124,6 +124,8 @@
     def getattr(space, w_obj, w_name):
         w_descr = space.lookup(w_obj, '__getattribute__')
         try:
+            if w_descr is None:   # obscure case
+                raise OperationError(space.w_AttributeError, space.w_None)
             return space.get_and_call_function(w_descr, w_obj, w_name)
         except OperationError, e:
             if not e.match(space, space.w_AttributeError):

Modified: pypy/dist/pypy/objspace/test/test_descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_descroperation.py	(original)
+++ pypy/dist/pypy/objspace/test/test_descroperation.py	Sat Mar 10 11:38:26 2007
@@ -268,3 +268,15 @@
             assert type(operate(A())) is str
             answer = 42
             raises(TypeError, operate, A())
+
+    def test_missing_getattribute(self):
+        class X(object): pass
+
+        class Y(X):
+          class __metaclass__(type):
+            def mro(cls):
+              return [cls, X]
+
+        x = X()
+        x.__class__ = Y
+        raises(AttributeError, getattr, x, 'a')



More information about the Pypy-commit mailing list