diff Lib/importlib/_bootstrap.py @ 57137:e25288bb6faf 3.1

Merged revisions 76146 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r76146 | brett.cannon | 2009-11-07 15:55:05 -0800 (Sat, 07 Nov 2009) | 6 lines When trying to write new bytecode, importlib was not catching the IOError thrown if the file happened to be read-only to keep the failure silent. Fixes issue #7187. Thanks, Dave Malcolm for the report and analysis of the problem. ........
author Brett Cannon <bcannon@gmail.com>
date Sat, 07 Nov 2009 23:57:20 +0000
parents d8280364c581
children 52823820dce1
line wrap: on
line diff
--- a/Lib/importlib/_bootstrap.py	Fri Nov 06 21:14:59 2009 +0000
+++ b/Lib/importlib/_bootstrap.py	Sat Nov 07 23:57:20 2009 +0000
@@ -522,9 +522,9 @@
         bytecode_path = self.bytecode_path(name)
         if not bytecode_path:
             bytecode_path = self._base_path + _suffix_list(imp.PY_COMPILED)[0]
-        file = _io.FileIO(bytecode_path, 'w')  # Assuming bytes.
         try:
-            with _closing(file) as bytecode_file:
+            # Assuming bytes.
+            with _closing(_io.FileIO(bytecode_path, 'w')) as bytecode_file:
                 bytecode_file.write(data)
                 return True
         except IOError as exc: