[pypy-svn] r11420 - in pypy/dist/pypy: interpreter translator/genc

tismer at codespeak.net tismer at codespeak.net
Mon Apr 25 14:32:21 CEST 2005


Author: tismer
Date: Mon Apr 25 14:32:21 2005
New Revision: 11420

Modified:
   pypy/dist/pypy/interpreter/gateway.py
   pypy/dist/pypy/translator/genc/pyobjtype.py
Log:
fixed gateway and genc to translate targetpypy1 -no-a again.
The problem was a py.path.local instance which I left
in ApplevelInterpClassafter my latest cache changes.

Modified genc to also ignore class attributes if they
are defined in NOT_RPYTHON_ATTRIBUTES.

This thing took me way too long to find out.
Maybe an alternative tagging mechanism is needed:
Not just enumerating attributesto be ignored, but
maybe also by tagging things like py.path.local
as NOT_RPYTHON, themselves?

Modified: pypy/dist/pypy/interpreter/gateway.py
==============================================================================
--- pypy/dist/pypy/interpreter/gateway.py	(original)
+++ pypy/dist/pypy/interpreter/gateway.py	Mon Apr 25 14:32:21 2005
@@ -565,7 +565,7 @@
     """ similar to applevel, but using translation to interp-level.
         This version maintains a cache folder with single files.
     """
-    NOT_RPYTHON_ATTRIBUTES = []
+    NOT_RPYTHON_ATTRIBUTES = ['cache_path', 'known_source']
 
     def __init__(self, source, filename = None, modname = 'applevelinterp', do_imports=False):
         "NOT_RPYTHON"
@@ -664,7 +664,7 @@
 known_source = {}
 
 # self-destruct on double-click:
-if __name__ == "__main__":
+def harakiri():
     import pypy._cache as _c
     from pypy.tool.getpy import py
     lp = py.path.local
@@ -672,6 +672,11 @@
         try:
             pth.remove()
         except: pass
+
+if __name__ == "__main__":
+    harakiri()
+
+del harakiri
 """ % GI_VERSION)
         import pypy._cache
         cls.known_source = pypy._cache.known_source

Modified: pypy/dist/pypy/translator/genc/pyobjtype.py
==============================================================================
--- pypy/dist/pypy/translator/genc/pyobjtype.py	(original)
+++ pypy/dist/pypy/translator/genc/pyobjtype.py	Mon Apr 25 14:32:21 2005
@@ -296,6 +296,7 @@
         def initclassobj():
             content = cls.__dict__.items()
             content.sort()
+            ignore = getattr(cls, 'NOT_RPYTHON_ATTRIBUTES', [])
             for key, value in content:
                 if key.startswith('__'):
                     if key in ['__module__', '__doc__', '__dict__',
@@ -313,6 +314,8 @@
                 if isinstance(value, FunctionType) and value not in self.translator.flowgraphs and self.translator.frozen:
                     print value
                     continue
+                if key in ignore:
+                    continue
                     
                 yield '%s.%s = %s' % (name, key, self.nameof(value))
 



More information about the Pypy-commit mailing list