[pypy-svn] r9048 - in pypy/dist/pypy/translator: . tool

pedronis at codespeak.net pedronis at codespeak.net
Thu Feb 10 16:46:06 CET 2005


Author: pedronis
Date: Thu Feb 10 16:46:06 2005
New Revision: 9048

Modified:
   pypy/dist/pypy/translator/geninterplevel.py
   pypy/dist/pypy/translator/tool/tointerplevel.py
Log:
- enable to exceptions raised by builtins support (needed by _classobj.py)

- be lazy accessing sys.* __bultin__.* stuff

- allow __new__ to be staticmethod-ified by the type ctr

- don't discard __repr__ in geninterplevel case

- NotImplemented support



Modified: pypy/dist/pypy/translator/geninterplevel.py
==============================================================================
--- pypy/dist/pypy/translator/geninterplevel.py	(original)
+++ pypy/dist/pypy/translator/geninterplevel.py	Thu Feb 10 16:46:06 2005
@@ -332,6 +332,9 @@
         else:
             return self.uniquelocalname('%s_%d' % (basename, n), seennames)
 
+    def nameof_NotImplementedType(self, value):
+        return "space.w_NotImplemented"
+
     def nameof_object(self, value):
         if type(value) is not object:
             # try to just wrap it?
@@ -533,11 +536,18 @@
                     break
             else:
                 raise Exception, '%r not found in any built-in module' % (func,)
-            name = self.uniquename('gbltin_' + func.__name__)
             if modname == '__builtin__':
-                self.initcode.append('m.%s = space.getattr(space.w_builtin, %s)'% (
-                    name, self.nameof(func.__name__)))
+                #self.initcode.append('m.%s = space.getattr(space.w_builtin, %s)'% (
+                #    name, self.nameof(func.__name__)))
+                # be lazy
+                return "(space.getattr(space.w_builtin, %s))" % self.nameof(func.__name__)
+            elif modname == 'sys':
+                # be lazy
+                return "(space.getattr(space.w_sys, %s))" % self.nameof(func.__name__)                
             else:
+                print ("WARNING: accessing builtin modules different from sys or __builtin__"
+                       " is likely producing non-sense")
+                name = self.uniquename('gbltin_' + func.__name__)
                 self.initcode.append('m.%s = space.getattr(%s, %s)' % (
                     name, self.nameof(module), self.nameof(func.__name__)))
         else:
@@ -585,7 +595,7 @@
             for key, value in content:
                 if key.startswith('__'):
                     if key in ['__module__', '__doc__', '__dict__',
-                               '__weakref__', '__repr__', '__metaclass__', '__slots__']:
+                               '__weakref__', '__metaclass__', '__slots__','__new__']:
                         continue
 
                 # redirect value through class interface, in order to
@@ -606,7 +616,7 @@
         self.initcode.appendnew('_dic = space.newdict([])')
         for key, value in cls.__dict__.items():
             if key.startswith('__'):
-                if key in ['__module__', '__metaclass__', '__slots__']:
+                if key in ['__module__', '__metaclass__', '__slots__','__new__']:
                     keyname = self.nameof(key)
                     valname = self.nameof(value)
                     self.initcode.appendnew("space.setitem(_dic, %s, %s)" % (
@@ -1118,6 +1128,7 @@
 # -*- coding: LATIN-1 -*-
 
 from pypy.interpreter.error import OperationError
+from pypy.interpreter.argument import Arguments
 '''
 
     RPY_SEP = "#*************************************************************"

Modified: pypy/dist/pypy/translator/tool/tointerplevel.py
==============================================================================
--- pypy/dist/pypy/translator/tool/tointerplevel.py	(original)
+++ pypy/dist/pypy/translator/tool/tointerplevel.py	Thu Feb 10 16:46:06 2005
@@ -4,9 +4,13 @@
 import os
 import new
 
+from pypy.objspace.flow.objspace import FlowObjSpace
 from pypy.translator.translator import Translator
 from pypy.translator.geninterplevel import GenRpy
 
+# change default
+FlowObjSpace.bultins_can_raise_exceptions = True
+
 def main():
     opt_parser = optparse.OptionParser(usage="usage: %prog [options] module-file obj-name...")
     opt_parser.add_option("--import-as", dest="as", type="string",



More information about the Pypy-commit mailing list