[Python-ideas] Add create mode to open()

Antoine Pitrou solipsis at pitrou.net
Thu Aug 18 11:35:09 CEST 2011


On Thu, 18 Aug 2011 07:54:32 +0200
David Townshend <aquavitae69 at gmail.com>
wrote:
> 
> The only problem is that O_EXCL may not be supported on all platforms.  Can
> anyone tell me which platforms these are?

That sounds unlikely. O_EXCL is a POSIX standard. It is also supported
under Windows by the _open/_wopen compatibility functions (which we use
for file I/O).

Probably there are very old systems which don't support it, and perhaps
new systems that don't implement it *correctly* (meaning not
atomically); for the former I'd say we just don't care (who's gonna run
Python 3 on a 1995 system?) and for the latter, well, if the OS
designers think it's fine, let's just expose it as it is.

As for NFS, there's an interesting comment from 2007 here:
http://lwn.net/Articles/251971/

“My NFS tester shows that it at least appears to work with Linux,
Solaris and FreeBSD:
http://www.dovecot.org/list/dovecot/2007-July/024102.html. Looking at
Linux 2.6 sources it doesn't look like it tries to implement a racy
O_EXCL check in client side (fs/nfs/nfs3proc.c nfs3_proc_create()), so
the test's results should be correct. I don't know if other OSes do
that. I guess it would be nice to have a better O_EXCL tester which
tries to catch race conditions.”

Regards

Antoine.





More information about the Python-ideas mailing list