[pypy-svn] r9374 - pypy/dist/pypy/tool

rxe at codespeak.net rxe at codespeak.net
Mon Feb 21 06:47:23 CET 2005


Author: rxe
Date: Mon Feb 21 06:47:23 2005
New Revision: 9374

Modified:
   pypy/dist/pypy/tool/traceinteractive.py
   pypy/dist/pypy/tool/traceop.py
Log:
* Fix up trace tools to work after lazy builtin module change.
* Remove unused option from ResultPrinter.



Modified: pypy/dist/pypy/tool/traceinteractive.py
==============================================================================
--- pypy/dist/pypy/tool/traceinteractive.py	(original)
+++ pypy/dist/pypy/tool/traceinteractive.py	Mon Feb 21 06:47:23 2005
@@ -43,13 +43,12 @@
             return None
 
     def global_matches(self, text):
-
         w_res = self.space.call_method(self.space.w_globals, "keys")
         namespace_keys = self.space.unwrap(w_res)
 
-        w_res = self.space.call_method(self.space.w_builtins, "keys")
+        w_res = self.space.call_method(self.space.builtin.getdict(), "keys")
         builtin_keys = self.space.unwrap(w_res)
-
+        
         matches = []
         n = len(text)
 
@@ -83,7 +82,7 @@
 
     def get_words(self, w_clz):
         s = self.space
-        w_dir_func = s.getitem(s.w_builtins, s.wrap("dir"))
+        w_dir_func = s.builtin.get("dir")
         w_res = s.call_function(w_dir_func, w_clz)
         return s.unwrap(w_res)
 
@@ -162,7 +161,7 @@
         self.tracelevel = tracelevel
 
         # XXX Do something better than this - I'm not really sure what is useful
-        # and what is (rxe)
+        # and what isn't (rxe)
         self.resprinter.operations_level = tracelevel
 
     def runcode(self, code):
@@ -181,18 +180,18 @@
             res = None
             if self.tracelevel:
                 res = s.getresult()
-                
+                s.settrace()
+                            
             # Did we modify __pytrace__
             tracelevel = s.unwrap(s.getitem(s.w_globals,
                                             s.wrap("__pytrace__")))
-            
+
             if tracelevel != self.tracelevel:
                 self.set_tracelevel(tracelevel)
 
-            if res is not None and self.tracelevel:
-                s.settrace()
+            if res is not None and self.tracelevel:                
                 self.resprinter.print_result(s, res)
-                
+                              
         except baseobjspace.OperationError, operationerr:
             if self.tracelevel:
                 res = s.getresult()

Modified: pypy/dist/pypy/tool/traceop.py
==============================================================================
--- pypy/dist/pypy/tool/traceop.py	(original)
+++ pypy/dist/pypy/tool/traceop.py	Mon Feb 21 06:47:23 2005
@@ -31,17 +31,14 @@
 class ResultPrinter:
 
     def __init__(self,
-                 skip_all_below_op = True,
                  operations_level = 2,
                  indentor = '  ',
-                 skip_bytecodes = ["PRINT_EXPR", "PRINT_ITEM", "PRINT_NEWLINE"],
-                 ):
+                 skip_bytecodes = ["PRINT_EXPR", "PRINT_ITEM", "PRINT_NEWLINE"]):
         
         # Configurable stuff
         self.indentor = indentor
         self.skip_bytecodes = skip_bytecodes
         self.operations_level = operations_level
-        self.skip_all_below_op = skip_all_below_op
         
         self.reset()
 
@@ -85,6 +82,7 @@
         self.print_line(s)        
 
     def print_bytecode(self, index, bytecode):
+
         # Don't allow bytecodes to be exposed if operations level is up
         if len(self.ops) >= self.operations_level:
             return
@@ -97,7 +95,7 @@
         s = " " * 17
         s += ">> %s%s" % (name, str_args)
         self.print_line_operations(s)
-
+        
 
     def print_op_leave(self, name, str_res):
         s = " " * 20
@@ -190,7 +188,6 @@
     try:
         # XXX Sure this won't go down well - didn't really want
         # to clutter up the interpeter code 
-        from pypy.interpreter.argument import Arguments
         from pypy.interpreter.function import Function, Method
 
         if isinstance(value, Function):
@@ -208,9 +205,9 @@
     l = []
     for arg in args:
         if frame and space.is_true(space.is_(arg, frame.w_globals)):
-            l.append('w_globals')
-        elif frame and space.is_true(space.is_(arg, space.w_builtins)):
-            l.append('w_builtins')
+            l.append('globals()')
+        elif frame and space.is_true(space.is_(arg, space.builtin)):
+            l.append('__builtin__')
         else:
             l.append(repr_value(space, arg))
             
@@ -252,6 +249,7 @@
             count += ii
         return count
 
+    # Note includes lazy loading of builtins
     res, traceres = perform_trace(tspace, app_test, tspace.wrap(5))
     print_result(tspace, traceres)
 



More information about the Pypy-commit mailing list