Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d783c8e

Browse files
committed
Issue #15833: don't raise an exception if importlib can't write byte-compiled
files. This fixes a regression introduced by 3.3. Patch by Charles-François Natali.
1 parent 03cb99c commit d783c8e

3 files changed

Lines changed: 1856 additions & 1846 deletions

File tree

Lib/importlib/_bootstrap.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,17 +1066,17 @@ def set_data(self, path, data, *, _mode=0o666):
10661066
except FileExistsError:
10671067
# Probably another Python process already created the dir.
10681068
continue
1069-
except PermissionError:
1070-
# If can't get proper access, then just forget about writing
1071-
# the data.
1069+
except OSError as exc:
1070+
# Could be a permission error, read-only filesystem: just forget
1071+
# about writing the data.
1072+
_verbose_message('could not create {!r}: {!r}', parent, exc)
10721073
return
10731074
try:
10741075
_write_atomic(path, data, _mode)
10751076
_verbose_message('created {!r}', path)
1076-
except (PermissionError, FileExistsError):
1077-
# Don't worry if you can't write bytecode or someone is writing
1078-
# it at the same time.
1079-
pass
1077+
except OSError as exc:
1078+
# Same as above: just don't write the bytecode.
1079+
_verbose_message('could not create {!r}: {!r}', path, exc)
10801080

10811081

10821082
class SourcelessFileLoader(FileLoader, _LoaderBasics):

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ Tests
127127
Build
128128
-----
129129

130+
- Issue #15833: Fix a regression in 3.3 that resulted in exceptions being
131+
raised if importlib failed to write byte-compiled files. This affected
132+
attempts to build Python out-of-tree from a read-only source directory.
133+
130134
- Issue #15923: Fix a mistake in ``asdl_c.py`` that resulted in a TypeError
131135
after 2801bf875a24 (see #15801).
132136

0 commit comments

Comments
 (0)