mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
The 2.0b2 change to write .pyc files in exclusive mode (if possible)
unintentionally caused them to get written in text mode under Windows. As a result, when .pyc files were later read-- in binary mode --the magic number was always wrong (note that .pyc magic numbers deliberately include \r and \n characters, so this was "good" breakage, 100% across all .pyc files, not random corruption in a subset). Fixed that.
This commit is contained in:
parent
3cc7e4d083
commit
42c83afd14
1 changed files with 6 additions and 1 deletions
|
@ -646,7 +646,12 @@ open_exclusive(char *filename)
|
||||||
*/
|
*/
|
||||||
int fd;
|
int fd;
|
||||||
(void) unlink(filename);
|
(void) unlink(filename);
|
||||||
fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC, 0666);
|
fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC
|
||||||
|
#ifdef O_BINARY
|
||||||
|
|O_BINARY /* necessary for Windows */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
, 0666);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return fdopen(fd, "wb");
|
return fdopen(fd, "wb");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue