Commits

Armin Rigo  committed 3102c6d

hello world

  • Participants
  • Parent commits 02143fb

Comments (0)

Files changed (3)

File pypy/interpreter/baseobjspace.py

 
 class PyPyError(Exception):
     "Raise this when you encounter an exceptional situation in PyPy itself."
-    pass
+    def __init__(self, space, operationerr):
+        self.space = space
+        self.operationerr = operationerr
+
 
 class ObjSpace:
     """Base class for the interpreter-level implementations of object spaces.

File pypy/interpreter/main.py

         code = compile(source, fname, 'exec')
         ec = executioncontext.ExecutionContext(space)
 
-        w_globals = ec.make_standard_w_globals()
-
-        space.setitem(w_globals,
-                      space.wrap("__name__"),
-                      space.wrap("__main__"))
+        w_mainmodule = space.newmodule(space.wrap("__main__"))
+        w_globals = space.getattr(w_mainmodule, space.wrap("__dict__"))
+        space.setitem(w_globals, space.wrap("__builtins__"),
+                      ec.get_w_builtins())
         
         frame = pyframe.PyFrame(space, code, w_globals, w_globals)
     except baseobjspace.OperationError, operationerr:
-        raise PyPyError(operationerr)
+        raise baseobjspace.PyPyError(space, operationerr)
     else:
         ec.eval_frame(frame)
 
 
     try:
         run_file(argv[1])
-    except baseobjspace.OperationError, operationerr:
+    except baseobjspace.PyPyError, pypyerr:
         # XXX insert exception info into the application-level sys.last_xxx
-        operationerr.print_detailed_traceback(space)
+        pypyerr.operationerr.print_detailed_traceback(pypyerr.space)
 
 if __name__ == '__main__':
     sys.exit(main(sys.argv))

File pypy/interpreter/test/hello_world.py

 
 def main():
     aStr = "hello world"
-    print len(aStr)
+    print aStr
 
 main()