[pypy-svn] r7524 - in pypy/trunk/src/pypy: interpreter objspace/std translator

arigo at codespeak.net arigo at codespeak.net
Sat Nov 20 18:31:03 CET 2004


Author: arigo
Date: Sat Nov 20 18:31:03 2004
New Revision: 7524

Modified:
   pypy/trunk/src/pypy/interpreter/error.py
   pypy/trunk/src/pypy/interpreter/extmodule.py
   pypy/trunk/src/pypy/objspace/std/fake.py
   pypy/trunk/src/pypy/translator/genc.py
Log:
More NOT_RPYTHON tags.


Modified: pypy/trunk/src/pypy/interpreter/error.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/error.py	(original)
+++ pypy/trunk/src/pypy/interpreter/error.py	Sat Nov 20 18:31:03 2004
@@ -31,11 +31,11 @@
         return space.exception_match(self.w_type, w_check_class)
 
     def __str__(self):
-        "Convenience for tracebacks."
+        "NOT_RPYTHON: Convenience for tracebacks."
         return '[%s: %s]' % (self.w_type, self.w_value)
 
     def errorstr(self, space):
-        "The exception class and value, as a string."
+        "NOT_RPYTHON: The exception class and value, as a string."
         exc_type  = space.unwrap(
             space.getattr(self.w_type, space.wrap('__name__')))
         exc_value = space.unwrap(space.str(self.w_value))
@@ -49,18 +49,19 @@
             return None
 
     def record_interpreter_traceback(self):
-        """Records the current traceback inside the interpreter.
+        """NOT_RPYTHON: Records the current traceback inside the interpreter.
         This traceback is only useful to debug the interpreter, not the
         application."""
         self.debug_excs.append(sys.exc_info())
 
     def print_application_traceback(self, space, file=None):
-        "Dump a standard application-level traceback."
+        "NOT_RPYTHON: Dump a standard application-level traceback."
         if file is None: file = sys.stderr
         self.print_app_tb_only(file)
         print >> file, self.errorstr(space)
 
     def print_app_tb_only(self, file):
+        "NOT_RPYTHON"
         tb = self.application_traceback
         if tb:
             import linecache
@@ -87,8 +88,8 @@
                 tb = tb.next
 
     def print_detailed_traceback(self, space=None, file=None):
-        """Dump a nice detailed interpreter- and application-level traceback,
-        useful to debug the interpreter."""
+        """NOT_RPYTHON: Dump a nice detailed interpreter- and
+        application-level traceback, useful to debug the interpreter."""
         if file is None: file = sys.stderr
         for i in range(len(self.debug_excs)-1, -1, -1):
             import traceback

Modified: pypy/trunk/src/pypy/interpreter/extmodule.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/extmodule.py	(original)
+++ pypy/trunk/src/pypy/interpreter/extmodule.py	Sat Nov 20 18:31:03 2004
@@ -22,7 +22,8 @@
     NOT_RPYTHON_ATTRIBUTES = ['__builtins__']
 
     def __init__(self, space, modulename, w_dict=None, sourcefile=None):
-        """Load the named built-in module, by default from the source file
+        """NOT_RPYTHON
+        Load the named built-in module, by default from the source file
         'pypy/module/<name>module.py', which is app-level Python code
         with a few special features that allow it to include interp-level
         bits.  (See pypy/module/test/foomodule.py)
@@ -73,13 +74,17 @@
                       space.w_builtins)
 
         # Temporarily install an '__applevel__' pseudo-module
-        sys.modules['__applevel__'] = BuiltinModule.AppModuleHack(self)
+        sys.modules['__applevel__'] = AppModuleHack(self)
 
         # Run the app-level module definition (xxxmodule.py)
         pycode.exec_code(space, w_dict, w_dict)
 
         # Remove the pseudo-module
         del sys.modules['__applevel__']
+        try:
+            del self.__applevel__
+        except AttributeError:
+            pass
 
         # Remove/restore the hooks unless they have been modified at app-level
         for name, w_hook in newhooks.items():
@@ -98,14 +103,14 @@
         del self.__saved_hooks
 
     def interplevelexec(self, w_codestring):
-        "'exec' a string at interp-level."
+        "NOT_RPYTHON: 'exec' a string at interp-level."
         codestring = self.space.unwrap(w_codestring)
         exec codestring in self.__dict__
         return self.space.w_None
 
     def interpleveleval(self, w_codestring):
-        """'eval' a string at interp-level.  The result must be None or
-        a wrapped object, which is returned to the caller."""
+        """NOT_RPYTHON: 'eval' a string at interp-level.  The result must
+        be None or a wrapped object, which is returned to the caller."""
         space = self.space
         codestring = space.unwrap(w_codestring)
         w_result = eval(codestring, self.__dict__)
@@ -114,15 +119,15 @@
         return w_result
 
     def interplevelexecfile(self, w_filename):
-        """'exec' a file at interp-level.  The file should be in the same
-        directory as the xxxmodule.py source file of the module."""
+        """NOT_RPYTON: 'exec' a file at interp-level.  The file should be in
+        the same directory as the xxxmodule.py source file of the module."""
         filename = self.space.unwrap(w_filename)
         filename = os.path.join(os.path.dirname(self.__file__), filename)
         execfile(filename, self.__dict__)
         return self.space.w_None
 
     def interplevelimport(self, w_modulename, w_globals, w_locals, w_fromlist):
-        """Hook for 'from __interplevel__ import something'.
+        """NOT_RPYTHON: Hook for 'from __interplevel__ import something'.
         If there is a wrapped interp-level object 'w_something', returns it.
         If there is an interp-level function 'def something(w_x, w_y...)',
         build an appropriate gateway and returns it.
@@ -150,15 +155,18 @@
                                        w_modulename, w_globals,
                                        w_locals, w_fromlist)
 
-    class AppModuleHack:
-        """For interp-level convenience: 'from __applevel__ import func'
-        imports the app-level function 'func' via an appropriate gateway.
-        """
-        def __init__(self, builtinmodule):
-            self.space = builtinmodule.space
-            self.w_dict = builtinmodule.w_dict
-        def __getattr__(self, name):
-            w_func = self.space.getitem(self.w_dict, self.space.wrap(name))
-            def caller(*args, **kwds):
-                return self.space.call_function(w_func, *args, **kwds)
-            return caller
+class AppModuleHack:
+    """NOT_RPYTHON
+    For interp-level convenience: 'from __applevel__ import func'
+    imports the app-level function 'func' via an appropriate gateway.
+    """
+    def __init__(self, builtinmodule):
+        self.space = builtinmodule.space
+        self.w_dict = builtinmodule.w_dict
+    def __getattr__(self, name):
+        if name.startswith('__'):
+            raise AttributeError, name
+        w_func = self.space.getitem(self.w_dict, self.space.wrap(name))
+        def caller(*args):
+            return self.space.call_function(w_func, *args)
+        return caller

Modified: pypy/trunk/src/pypy/objspace/std/fake.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/fake.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/fake.py	Sat Nov 20 18:31:03 2004
@@ -16,6 +16,7 @@
 
 # real-to-wrapped exceptions
 def wrap_exception(space):
+    "NOT_RPYTHON"  # XXX this needs to end up in the translated code somehow!
     exc, value, tb = sys.exc_info()
     if exc is OperationError:
         raise exc, value, tb   # just re-raise it

Modified: pypy/trunk/src/pypy/translator/genc.py
==============================================================================
--- pypy/trunk/src/pypy/translator/genc.py	(original)
+++ pypy/trunk/src/pypy/translator/genc.py	Sat Nov 20 18:31:03 2004
@@ -103,8 +103,10 @@
         return name
 
     def nameof_module(self, value):
-        assert not hasattr(value, "__file__") or \
-               not (value.__file__.endswith('.pyc') or value.__file__.endswith('.py') or value.__file__.endswith('.pyo')), \
+        assert value is os or not hasattr(value, "__file__") or \
+               not (value.__file__.endswith('.pyc') or
+                    value.__file__.endswith('.py') or
+                    value.__file__.endswith('.pyo')), \
                "%r is not a builtin module (probably :)"%value
         name = self.uniquename('mod%s'%value.__name__)
         self.globalobjects.append(name)



More information about the Pypy-commit mailing list