[pypy-svn] r74824 - pypy/trunk/pypy/module/cpyext

afa at codespeak.net afa at codespeak.net
Thu May 27 20:06:07 CEST 2010


Author: afa
Date: Thu May 27 20:06:06 2010
New Revision: 74824

Modified:
   pypy/trunk/pypy/module/cpyext/typeobject.py
Log:
Don't crash when _PyType_Lookup() is given an invalid attribute name


Modified: pypy/trunk/pypy/module/cpyext/typeobject.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/typeobject.py	(original)
+++ pypy/trunk/pypy/module/cpyext/typeobject.py	Thu May 27 20:06:06 2010
@@ -687,10 +687,14 @@
 def _PyType_Lookup(space, type, w_name):
     """Internal API to look for a name through the MRO.
     This returns a borrowed reference, and doesn't set an exception!"""
-    py_type = rffi.cast(PyObject, type)
-    w_type = from_ref(space, py_type)
+    w_type = from_ref(space, rffi.cast(PyObject, type))
     assert isinstance(w_type, W_TypeObject)
+
+    if not space.isinstance_w(w_name, space.w_str):
+        return None
     name = space.str_w(w_name)
     w_obj = w_type.lookup(name)
     return borrow_from(w_type, w_obj)
 
+
+



More information about the Pypy-commit mailing list