[plug] python head+wall issue

Cameron Patrick cameron at patrick.wattle.id.au
Mon Dec 29 20:26:35 WST 2003


On Mon, Dec 29, 2003 at 08:06:17PM +0800, James Devenish wrote:

| The man page says "The fd references a socket, not a file." or "The fd
| is not open for writing."

On my machine:

       EBADF or EINVAL
              The fd is not open for writing.

       EINVAL The fd does not reference a regular file.

Which is near enough :-)

I can confirm what Craig saw in 2.4.21 too so I don't think it's a
kernel issue.  Hmm, stracing foo I see that the argument isn't being
cast to a long long properly in my test program.  When I change that, it
works.  D'oh!

I notice in my strace python output, though:

	open("foo.py", O_RDONLY|O_LARGEFILE)    = 4

Bingo!  Now to work out /why/ it's being opened read-only...  Aha, from
http://localhost/doc/python/html/lib/built-in-funcs.html#built-in-funcs:

	Modes 'r+', 'w+' and 'a+' open the file for updating (note that
	'w+' truncates the file). Append 'b' to the mode to open the
	file in binary mode, on systems that differentiate between
	binary and text files (else it is ignored). If the file cannot
	be opened, IOError is raised.

In particular, 'rw' looks like it /doesn't/ work the way it does in C.
Use r+ in python and all seems to be good.

Cameron.




More information about the plug mailing list