[pypy-commit] pypy default: Use with statement here instead of closing the file manually.

Manuel Jacob noreply at buildbot.pypy.org
Mon May 19 04:40:01 CEST 2014


Author: Manuel Jacob
Branch: 
Changeset: r71580:5752672ddec8
Date: 2014-05-19 04:39 +0200
http://bitbucket.org/pypy/pypy/changeset/5752672ddec8/

Log:	Use with statement here instead of closing the file manually.

diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -608,9 +608,8 @@
                 python_startup = readenv and os.getenv('PYTHONSTARTUP')
                 if python_startup:
                     try:
-                        f = open(python_startup)
-                        startup = f.read()
-                        f.close()
+                        with open(python_startup) as f:
+                            startup = f.read()
                     except IOError as e:
                         print >> sys.stderr, "Could not open PYTHONSTARTUP"
                         print >> sys.stderr, "IOError:", e


More information about the pypy-commit mailing list