Commits

Brian Kearns committed 4ffacf3

modernization

Comments (0)

Files changed (1)

lib_pypy/disassembler.py

 view on things
 """
 
+from __future__ import print_function
 import sys
 import types
 import inspect
         x = x.func_code
     if hasattr(x, '__dict__'):
         xxx
-        items = x.__dict__.items()
-        items.sort()
+        items = sorted(x.__dict__.items())
         for name, x1 in items:
             if type(x1) in (types.MethodType,
                             types.FunctionType,
                             types.CodeType,
                             types.ClassType):
-                print "Disassembly of %s:" % name
+                print("Disassembly of %s:" % name)
                 try:
                     dis(x1)
                 except TypeError, msg:
-                    print "Sorry:", msg
-                print
+                    print("Sorry:", msg)
+                print()
     elif hasattr(x, 'co_code'):
         return disassemble(x)
     elif isinstance(x, str):
         return disassemble_string(x)
     else:
-        raise TypeError, \
-              "don't know how to disassemble %s objects" % \
-              type(x).__name__
+        raise TypeError("don't know how to disassemble %s objects" % \
+              type(x).__name__)
 
 def distb(tb=None):
     """Disassemble a traceback (default: last traceback)."""
         try:
             tb = sys.last_traceback
         except AttributeError:
-            raise RuntimeError, "no last traceback to disassemble"
+            raise RuntimeError("no last traceback to disassemble")
         while tb.tb_next: tb = tb.tb_next
     disassemble(tb.tb_frame.f_code, tb.tb_lasti)
 
             extended_arg = 0
             i = i+2
             if op == EXTENDED_ARG:
-                extended_arg = oparg*65536L
+                extended_arg = oparg*65536
             if op in hasconst:
                 opargstr = repr(co.co_consts[oparg])
             elif op in hasname:
         op = ord(c)
         if i == lasti:
             xxx
-            print '-->',
+            print('-->', end=' ')
         else:
             xxx
-            print '   ',
+            print('   ', end=' ')
         if i in labels:
             xxx
-            print '>>',
+            print('>>', end=' ')
         else:
             xxx
-            print '  ',
+            print('  ', end=' ')
         xxxx
-        print repr(i).rjust(4),
-        print opname[op].ljust(15),
+        print(repr(i).rjust(4), end=' ')
+        print(opname[op].ljust(15), end=' ')
         i = i+1
         if op >= HAVE_ARGUMENT:
             oparg = ord(code[i]) + ord(code[i+1])*256
             i = i+2
             xxx
-            print repr(oparg).rjust(5),
+            print(repr(oparg).rjust(5), end=' ')
             if op in hasconst:
                 if constants:
                     xxx
-                    print '(' + repr(constants[oparg]) + ')',
+                    print('(' + repr(constants[oparg]) + ')', end=' ')
                 else:
                     xxx
-                    print '(%d)'%oparg,
+                    print('(%d)'%oparg, end=' ')
             elif op in hasname:
                 if names is not None:
                     xxx
-                    print '(' + names[oparg] + ')',
+                    print('(' + names[oparg] + ')', end=' ')
                 else:
                     xxx
-                    print '(%d)'%oparg,
+                    print('(%d)'%oparg, end=' ')
             elif op in hasjrel:
                 xxx
-                print '(to ' + repr(i + oparg) + ')',
+                print('(to ' + repr(i + oparg) + ')', end=' ')
             elif op in haslocal:
                 if varnames:
                     xxx
-                    print '(' + varnames[oparg] + ')',
+                    print('(' + varnames[oparg] + ')', end=' ')
                 else:
                     xxx
-                    print '(%d)' % oparg,
+                    print('(%d)' % oparg, end=' ')
             elif op in hascompare:
                 xxx
-                print '(' + cmp_op[oparg] + ')',
+                print('(' + cmp_op[oparg] + ')', end=' ')
         xxx
-        print
+        print()
 
 disco = disassemble                     # XXX For backwards compatibility
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.