diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-24 17:47:02 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-24 17:47:02 (GMT) |
commit | cb0ec7dc425bbcd6a3325b2012f6843320219d34 (patch) | |
tree | 77c829f3e1661a94fd10d9fbac997707a466ddb3 /Lib/importlib/_bootstrap.py | |
parent | cbf9d5f6cd9c9f2fab1dee39561817476bcce944 (diff) | |
parent | ba0a3edd26bce7abf435ac4103b707e8ea1c3e7e (diff) | |
download | cpython-cb0ec7dc425bbcd6a3325b2012f6843320219d34.zip cpython-cb0ec7dc425bbcd6a3325b2012f6843320219d34.tar.gz cpython-cb0ec7dc425bbcd6a3325b2012f6843320219d34.tar.bz2 |
Merge
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 6bd6c09..861900c 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1042,9 +1042,13 @@ class SourceFileLoader(FileLoader, SourceLoader): def _cache_bytecode(self, source_path, bytecode_path, data): # Adapt between the two APIs - return self.set_data(bytecode_path, data, source_path=source_path) + try: + mode = _os.stat(source_path).st_mode + except OSError: + mode = 0o666 + return self.set_data(bytecode_path, data, _mode=mode) - def set_data(self, path, data, *, source_path=None): + def set_data(self, path, data, *, _mode=0o666): """Write bytes data to a file.""" parent, filename = _path_split(path) path_parts = [] @@ -1064,14 +1068,8 @@ class SourceFileLoader(FileLoader, SourceLoader): # If can't get proper access, then just forget about writing # the data. return - mode = 0o666 - if source_path is not None: - try: - mode = _os.stat(source_path).st_mode - except OSError: - pass try: - _write_atomic(path, data, mode) + _write_atomic(path, data, _mode) _verbose_message('created {!r}', path) except (PermissionError, FileExistsError): # Don't worry if you can't write bytecode or someone is writing |