[pypy-svn] r40018 - pypy/dist/pypy/translator/goal

ac at codespeak.net ac at codespeak.net
Wed Mar 7 12:13:36 CET 2007


Author: ac
Date: Wed Mar  7 12:13:34 2007
New Revision: 40018

Modified:
   pypy/dist/pypy/translator/goal/app_main.py
Log:
Print traceback if we get an exception when running $PYTHONSTARTUP.
Use os.getenv since os.environ currently is buggy :(



Modified: pypy/dist/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/app_main.py	(original)
+++ pypy/dist/pypy/translator/goal/app_main.py	Wed Mar  7 12:13:34 2007
@@ -268,13 +268,17 @@
             sys.argv.append('')
             go_interactive = True
             
-        if go_interactive or os.environ.get('PYTHONINSPECT'):
-            python_startup = os.environ.get('PYTHONSTARTUP')
+        if go_interactive or os.getenv('PYTHONINSPECT'):
+            python_startup = os.getenv('PYTHONSTARTUP')
             if python_startup:
                 try:
-                    execfile(python_startup, mainmodule.__dict__)
-                except:
+                    startup = open(python_startup).read()
+                except IOError:
                     pass
+                else:
+                    def run_it():
+                        exec startup in mainmodule.__dict__
+                    run_toplevel(run_it)
             print >> sys.stderr, "debug: importing code" 
             import code
             print >> sys.stderr, "debug: calling code.interact()"



More information about the Pypy-commit mailing list