Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 14921:3db8b8031a6a legacy-trunk
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.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Fri, 29 Sep 2000 04:03:10 +0000 |
| parents | 89b2aee43e0b |
| children | 5d41ca49a10a |
line wrap: on
line diff
--- a/Python/import.c Fri Sep 29 00:30:05 2000 +0000 +++ b/Python/import.c Fri Sep 29 04:03:10 2000 +0000 @@ -646,7 +646,12 @@ */ int fd; (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) return NULL; return fdopen(fd, "wb");
