summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-11-07 23:55:05 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-11-07 23:55:05 (GMT)
commite52c919d67a20b235de008aed8a165778d78b2a9 (patch)
tree99b0dd63368ae71bc8dd00ff8d6cd6848e1fabfd /Lib/importlib/_bootstrap.py
parent1b184d547f9421b586e92984960edc01bbb36307 (diff)
downloadcpython-e52c919d67a20b235de008aed8a165778d78b2a9.zip
cpython-e52c919d67a20b235de008aed8a165778d78b2a9.tar.gz
cpython-e52c919d67a20b235de008aed8a165778d78b2a9.tar.bz2
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.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 466b287..02f5c49 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -526,9 +526,9 @@ class _PyPycFileLoader(PyPycLoader, _PyFileLoader):
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: