[2.7] bpo-25083: Python 2 can sometimes create incorrect .pyc files by tzickel · Pull Request #8449 · python/cpython
Python 2 never checked for I/O error when reading .py files and
thus could mistake an I/O error for EOF and create incorrect .pyc
files. This adds an check for this and aborts on an error.
methane
changed the title
bpo-25083: Python 2 can sometimes create incorrect .pyc files
[2.7] bpo-25083: Python 2 can sometimes create incorrect .pyc files
This looks good except for the use of E_EOF. That should be reserved for end-of-file, but in this case here we're not getting to the end of file.
I don't see a good E_ constant for read errors in the current list. Could you add a new one in Include/errcode.h and Python/pythonrun.c, so that this gets a proper error message?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, should we call clearerr() here? In case if fp is used again.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.
Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.
Python 2 never checked for I/O error when reading .py files and thus could mistake an I/O error for EOF and create incorrect .pyc files. This adds an check for this and aborts on an error.
Thanks for making the requested changes!
@vstinner: please review the changes made to this pull request.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I would prefer that someone else merge it.
@encukou I'm waiting for the convincing part :) I think it's best to merge this ASAP (if it's plan to be used), so it has maximum exposure before a new release.