New submission from Quentin Agren <quentin.ag...@gmail.com>:
Hi, This is the first issue I submit so please correct me if I do anything wrong. Description of the issue: imporlib logs 'wrote <path to .pyc file>' even when file creation fails with OSError (for lack of write persmission for example) Reproducing the bug in Python 3.6 on ubuntu 16.04: cd /home/quentin/tmp mkdir __pycache__ chmod -R -w __pycache__ echo '1 + 1' > spam.py python -vv -c'import spam' 2>&1 | grep '__pycache__/spam' Output: # could not create '/home/quentin/tmp/__pycache__/spam.cpython-36.pyc': PermissionError(13, 'Permission denied') # wrote '/home/quentin/tmp/__pycache__/spam.cpython-36.pyc' Reason: SourceFileLoader.set_data() silences OSError raised by _write_atomic (importlib/_bootstrap_external.py line 875) Then SourceLoader.get_code() does not see that something went awry and logs file creation (same file, line 789) If it is worth fixing I would be glad to contribute a patch, but would probably need a little guidance. ---------- components: Library (Lib) messages: 328029 nosy: qagren priority: normal severity: normal status: open title: Incorrect logging in importlib when '.pyc' file creation fails type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35024> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com