mirror of
https://github.com/python/cpython.git
synced 2025-09-28 19:25:27 +00:00
Merge
This commit is contained in:
commit
cb0ec7dc42
2 changed files with 1894 additions and 1899 deletions
|
@ -1042,9 +1042,13 @@ class SourceFileLoader(FileLoader, SourceLoader):
|
||||||
|
|
||||||
def _cache_bytecode(self, source_path, bytecode_path, data):
|
def _cache_bytecode(self, source_path, bytecode_path, data):
|
||||||
# Adapt between the two APIs
|
# 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."""
|
"""Write bytes data to a file."""
|
||||||
parent, filename = _path_split(path)
|
parent, filename = _path_split(path)
|
||||||
path_parts = []
|
path_parts = []
|
||||||
|
@ -1064,14 +1068,8 @@ class SourceFileLoader(FileLoader, SourceLoader):
|
||||||
# If can't get proper access, then just forget about writing
|
# If can't get proper access, then just forget about writing
|
||||||
# the data.
|
# the data.
|
||||||
return
|
return
|
||||||
mode = 0o666
|
|
||||||
if source_path is not None:
|
|
||||||
try:
|
|
||||||
mode = _os.stat(source_path).st_mode
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
try:
|
try:
|
||||||
_write_atomic(path, data, mode)
|
_write_atomic(path, data, _mode)
|
||||||
_verbose_message('created {!r}', path)
|
_verbose_message('created {!r}', path)
|
||||||
except (PermissionError, FileExistsError):
|
except (PermissionError, FileExistsError):
|
||||||
# Don't worry if you can't write bytecode or someone is writing
|
# Don't worry if you can't write bytecode or someone is writing
|
||||||
|
|
3777
Python/importlib.h
3777
Python/importlib.h
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue