Commits

mattip committed 241e035

adapt syntax to py3k

  • Participants
  • Parent commits 97ac199
  • Branches py3k

Comments (0)

Files changed (2)

         config = make_config(option)
     try:
         space = make_objspace(config)
-    except OperationError, e:
+    except OperationError as e:
         check_keyboard_interrupt(e)
         if option.verbose:
             import traceback
         assert body.startswith('(')
         src = py.code.Source("def anonymous" + body)
         d = {}
-        exec src.compile() in d
+        exec(src.compile() in d)
         return d['anonymous'](*args)
 
     def wrap(self, obj):
     pyfile.write(helpers + str(source))
     res, stdout, stderr = runsubprocess.run_subprocess(
         python, [str(pyfile)])
-    print source
-    print >> sys.stdout, stdout
-    print >> sys.stderr, stderr
+    print(source)
+    print(stdout, file=sys.stdout)
+    print(stderr, file=sys.stderr)
     if res > 0:
         raise AssertionError("Subprocess failed")
 
     try:
         if e.w_type.name == 'KeyboardInterrupt':
             tb = sys.exc_info()[2]
-            raise OpErrKeyboardInterrupt, OpErrKeyboardInterrupt(), tb
+            raise OpErrKeyboardInterrupt(OpErrKeyboardInterrupt(), tb)
     except AttributeError:
         pass
 
     def runtest(self):
         try:
             super(IntTestFunction, self).runtest()
-        except OperationError, e:
+        except OperationError as e:
             check_keyboard_interrupt(e)
             raise
-        except Exception, e:
+        except Exception as e:
             cls = e.__class__
             while cls is not Exception:
                 if cls.__name__ == 'DistutilsPlatformError':
     def execute_appex(self, space, target, *args):
         try:
             target(*args)
-        except OperationError, e:
+        except OperationError as e:
             tb = sys.exc_info()[2]
             if e.match(space, space.w_KeyboardInterrupt):
-                raise OpErrKeyboardInterrupt, OpErrKeyboardInterrupt(), tb
+                raise OpErrKeyboardInterrupt(OpErrKeyboardInterrupt(), tb)
             appexcinfo = appsupport.AppExceptionInfo(space, e)
             if appexcinfo.traceback:
-                raise AppError, AppError(appexcinfo), tb
+                raise AppError(AppError(appexcinfo), tb)
             raise
 
     def runtest(self):
         space = gettestobjspace()
         filename = self._getdynfilename(target)
         func = app2interp_temp(src, filename=filename)
-        print "executing", func
+        print("executing", func)
         self.execute_appex(space, func, space)
 
     def repr_failure(self, excinfo):

pypy/translator/goal/app_main.py

 # this indirection is needed to be able to import this module on python2, else
 # we have a SyntaxError: unqualified exec in a nested function
 def exec_(src, dic):
+    print('Calling exec(%s, %s)',src,dic)
     exec(src, dic)
 
 def run_command_line(interactive,