[Python-Dev] .pyc broken on Windows -- anywhere else?

Eric S. Raymond esr@thyrsus.com
Thu, 28 Sep 2000 23:59:12 -0400

Tim Peters <tim_one@email.msn.com>:
> 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

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