Author qagren
Recipients qagren
Date 2018-10-19.04:00:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>

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' >
python -vv -c'import spam' 2>&1 | grep '__pycache__/spam'

# could not create '/home/quentin/tmp/__pycache__/spam.cpython-36.pyc': PermissionError(13, 'Permission denied')
# wrote '/home/quentin/tmp/__pycache__/spam.cpython-36.pyc'

SourceFileLoader.set_data() silences OSError raised by _write_atomic (importlib/ 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.
Date User Action Args
2018-10-19 04:00:41qagrensetrecipients: + qagren
2018-10-19 04:00:41qagrensetmessageid: <>
2018-10-19 04:00:41qagrenlinkissue35024 messages
2018-10-19 04:00:41qagrencreate