Commits

Michael Hudson-Doyle  committed 0e11d97

try to import readline if we have it.

add __name__ (=='__main__') to interactive namespace

  • Participants
  • Parent commits 1d77c09

Comments (0)

Files changed (1)

File pypy/interpreter/interactive.py

         self.space = objspace()
         self.ec = executioncontext.ExecutionContext(self.space)
         self.w_globals = self.ec.make_standard_w_globals()
+        self.space.setitem(self.w_globals,
+                           self.space.wrap("__name__"),
+                           self.space.wrap("__main__"))
 
     def interact(self):
         banner = "Python %s in pypy\n%s / %s" % (
         code.InteractiveConsole.interact(self, banner)
 
     def runcode(self, code):
-        # ah ha!
         frame = pyframe.PyFrame(self.space, code,
                                 self.w_globals, self.w_globals)
         try:
         return 0
 
 if __name__ == '__main__':
+    try:
+        import readline
+    except ImportError:
+        pass
     # object space selection
     if len(sys.argv) < 2:
         choice = 'trivial'   # default