mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
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.
This commit is contained in:
parent
1b184d547f
commit
e52c919d67
4 changed files with 32 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue