summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-10-14 22:14:36 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-10-14 22:14:36 (GMT)
commitea5d827b729e425751428153318ecc348cc0be50 (patch)
tree1997afdc83eb0dca7c00c11a71419579e94b871a /Lib/doctest.py
parent3d400b7a58a9f6e338048593ae19ab3cc92a8cd3 (diff)
downloadcpython-ea5d827b729e425751428153318ecc348cc0be50.zip
cpython-ea5d827b729e425751428153318ecc348cc0be50.tar.gz
cpython-ea5d827b729e425751428153318ecc348cc0be50.tar.bz2
Merged revisions 85503 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85503 | antoine.pitrou | 2010-10-15 00:11:44 +0200 (ven., 15 oct. 2010) | 2 lines More proper closing of files ........
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r--Lib/doctest.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 21b6cc3..7554a1f 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -214,7 +214,8 @@ def _load_testfile(filename, package, module_relative, encoding):
# get_data() opens files as 'rb', so one must do the equivalent
# conversion as universal newlines would do.
return file_contents.replace(os.linesep, '\n'), filename
- return open(filename, encoding=encoding).read(), filename
+ with open(filename, encoding=encoding) as f:
+ return f.read(), filename
def _indent(s, indent=4):
"""
@@ -2503,7 +2504,8 @@ def debug_script(src, pm=False, globs=None):
if pm:
try:
- exec(open(srcfilename).read(), globs, globs)
+ with open(srcfilename) as f:
+ exec(f.read(), globs, globs)
except:
print(sys.exc_info()[1])
pdb.post_mortem(sys.exc_info()[2])