Charles-François Natali <neolo...@free.fr> added the comment: > Here is a patch for import.c.
Looks good to me. > This new patch also fixes importlib. """ path_tmp = path + '.tmp' with _io.FileIO(path_tmp, 'wb') as file: file.write(data) _os.rename(path_tmp, path) """ I don't know exactly the context in which this code runs, but you can have a corruption if multiple processes try to write the bytecode file at the same time, since they'll all open the .tmp file: it should be opened with O_EXCL. Also, as a side note, I'm wondering whether this type of check: """ if not sys.platform.startswith('win'): # On POSIX-like platforms, renaming is atomic """ couldn't be rewritten as """ if os.name == 'posix': # On POSIX-like platforms, renaming is atomic """ Fox example, does OS-X report as POSIX? ---------- nosy: +neologix _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13146> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com