[pypy-svn] r7382 - in pypy/trunk/src/pypy: annotation objspace/std

hpk at codespeak.net hpk at codespeak.net
Thu Nov 18 16:00:58 CET 2004


Author: hpk
Date: Thu Nov 18 16:00:57 2004
New Revision: 7382

Modified:
   pypy/trunk/src/pypy/annotation/builtin.py
   pypy/trunk/src/pypy/objspace/std/objspace.py
Log:
- convert annotator/builtin's getattr/hasattr raising of 
  RPython-Errors into printing warnings 

- added builtin_callable() (returning just SomeBool())

- it seems genc.py is started now! 



Modified: pypy/trunk/src/pypy/annotation/builtin.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/builtin.py	(original)
+++ pypy/trunk/src/pypy/annotation/builtin.py	Thu Nov 18 16:00:57 2004
@@ -65,16 +65,20 @@
     else:
         return SomeBool()
 
-def builtin_getattr(s_obj, s_attr):
+def builtin_getattr(s_obj, s_attr, s_default=None):
     if not s_attr.is_constant() or not isinstance(s_attr.const, str):
-        raise Exception, 'getattr(%r, %r) is not RPythonic enough' % (
-            s_obj, s_attr)
+        print "UN-RPYTHONIC-WARNING", \
+              'getattr(%r, %r) is not RPythonic enough' % (s_obj, s_attr)
+        return SomeObject()
     return s_obj.getattr(s_attr)
 
 def builtin_hasattr(s_obj, s_attr):
     if not s_attr.is_constant() or not isinstance(s_attr.const, str):
-        raise Exception, 'hasattr(%r, %r) is not RPythonic enough' % (
-            s_obj, s_attr)
+        print "UN-RPYTHONIC-WARNING", \
+              'hasattr(%r, %r) is not RPythonic enough' % (s_obj, s_attr)
+    return SomeBool()
+
+def builtin_callable(s_obj):
     return SomeBool()
 
 def builtin_tuple(s_iterable):

Modified: pypy/trunk/src/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/objspace.py	Thu Nov 18 16:00:57 2004
@@ -254,7 +254,9 @@
         # anything below this line is implicitly XXX'ed
         if isinstance(x, type(Exception)) and issubclass(x, Exception):
             if hasattr(self, 'w_' + x.__name__):
-                return getattr(self, 'w_' + x.__name__)
+                w_result = getattr(self, 'w_' + x.__name__)
+                assert isinstance(w_result, W_TypeObject)
+                return w_result 
         if isinstance(x, type):
             ft = self.loadfromcache(x, fake_type, self._faketypecache)
             return self.gettypeobject(ft.typedef)



More information about the Pypy-commit mailing list