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

Fred L. Drake, Jr. fdrake@beopen.com
Thu, 28 Sep 2000 23:48:49 -0400 (EDT)


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