.pyc broken on Windows -- anywhere else?
Tim writes: That is, .pyc's don't work at all anymore on Windows: Python *always* thinks they have a bad magic number. Elsewhere? Just grabbed the latest from CVS - .pyc is still fine on Tru64 Unix... Mark -- Email - m.favas@per.dem.csiro.au Postal - Mark C Favas Phone - +61 8 9333 6268, 041 892 6074 CSIRO Exploration & Mining Fax - +61 8 9387 8642 Private Bag No 5 Wembley, Western Australia 6913
[Tim]
That is, .pyc's don't work at all anymore on Windows: Python *always* thinks they have a bad magic number. Elsewhere?
[Mark Favas]
Just grabbed the latest from CVS - .pyc is still fine on Tru64 Unix...
Good clue! Looks like Guido broke this on Windows when adding some "exclusive write" silliness <wink> for Unixoids. I'll try to make time tonight to understand it (*looks* like fdopen is too late to ask for binary mode under Windows ...).
Any Unix geek awake? import.c has this, starting at line 640: #if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC) ... fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC, 0666); I need to add O_BINARY to this soup to fix .pyc's under Windows. Is O_BINARY customarily defined on Unices? I realize Unices don't *need* it, the question is whether it will break Unices if it's there ...
Nevermind. Fixed it in a way that will be safe everywhere.
-----Original Message----- From: python-dev-admin@python.org [mailto:python-dev-admin@python.org]On Behalf Of Tim Peters Sent: Thursday, September 28, 2000 11:41 PM To: Mark Favas; python-dev@python.org Subject: RE: [Python-Dev] .pyc broken on Windows -- anywhere else?
Any Unix geek awake? import.c has this, starting at line 640:
#if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC) ... fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC, 0666);
I need to add O_BINARY to this soup to fix .pyc's under Windows. Is O_BINARY customarily defined on Unices? I realize Unices don't *need* it, the question is whether it will break Unices if it's there ...
Tim Peters writes:
Any Unix geek awake? import.c has this, starting at line 640:
Probably quite a few!
#if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC) ... fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC, 0666);
I need to add O_BINARY to this soup to fix .pyc's under Windows. Is O_BINARY customarily defined on Unices? I realize Unices don't *need* it, the question is whether it will break Unices if it's there ...
I think it varies substantially. I just checked on a FreeBSD machine in /use/include/*.h and /usr/include/*/*.h, and grep said it wasn't there. It is defined on my Linux box, however. Since O_BINARY is a no-op for Unix, you can do this: #if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC) #ifndef O_BINARY #define O_BINARY (0) #endif ... fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC, 0666); -Fred -- Fred L. Drake, Jr. <fdrake at beopen.com> BeOpen PythonLabs Team Member
Eric S. Raymond writes:
It will. In particular, there us no such flag on Linux. However the workaround is trivial:
Ah, looking back at my grep output, I see that it's defined by a lot of libraries, but not the standard headers. It *is* defined by the Apache API headers, kpathsea, MySQL, OpenSSL, and Qt. And that's just from what I have installed. -Fred -- Fred L. Drake, Jr. <fdrake at beopen.com> BeOpen PythonLabs Team Member
Tim Peters
Any Unix geek awake? import.c has this, starting at line 640:
#if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC) ... fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC, 0666);
I need to add O_BINARY to this soup to fix .pyc's under Windows. Is O_BINARY customarily defined on Unices? I realize Unices don't *need* it, the question is whether it will break Unices if it's there ...
It will. In particular, there us no such flag on Linux. However the workaround is trivial: 1. Make your flagargument O_EXCL|O_CREAT|O_WRONLY|O_TRUNC|O_BINARY 2. Above it somewhere, write #ifndef O_BINARY #define O_BINARY 0 #endif Quite painless. -- <a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a> Society in every state is a blessing, but government even in its best state is but a necessary evil; in its worst state an intolerable one; for when we suffer, or are exposed to the same miseries *by a government*, which we might expect in a country *without government*, our calamities is heightened by reflecting that we furnish the means by which we suffer." -- Thomas Paine
participants (4)
-
Eric S. Raymond
-
Fred L. Drake, Jr.
-
Mark Favas
-
Tim Peters