Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread Martin v. Löwis
> Same here. In fact, is there a good reason to have mkstemp() return the > fd (except backward compatibility)? Except for backwards compatibility: is there a good reason to keep os.mkstemp at all? The tradition is that all APIs in os expose the "system" calls as-is, i.e. they don't try to adjus

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread Scott Dial
Greg Ewing wrote: [EMAIL PROTECTED] wrote: I'm not disagreeing with you, but it seems odd that os.fdopen doesn't simply obey the mode of the file descriptor it receives as its argument I'm not even sure if it's possible to find out the mode that a file descriptor was opened with -- is it?

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread Greg Ewing
[EMAIL PROTECTED] wrote: I'm not disagreeing with you, but it seems odd that os.fdopen doesn't simply obey the mode of the file descriptor it receives as its argument I'm not even sure if it's possible to find out the mode that a file descriptor was opened with -- is it? Certainly there's no w

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread Greg Ewing
Guido van Rossum wrote: IMO mkstemp() is a major pain because you have to use raw file descriptors on the return value. I'd much rather recommend [Named]TemporaryFile which return streams. The problem with NamedTemporaryFile is that it deletes the file as soon as you close it, which makes the n

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread Giovanni Bajo
On Tue, 29 Apr 2008 17:15:11 +1200, Greg Ewing wrote: > [EMAIL PROTECTED] wrote: >> Guido> Have we documented the alternatives well enough? >> >> I suppose we could document explicitly how to use mkstemp() in place of >> mktemp(), but the difference in return value is fairly modest: > > I'd

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread Greg Ewing
[EMAIL PROTECTED] wrote: Guido> Have we documented the alternatives well enough? I suppose we could document explicitly how to use mkstemp() in place of mktemp(), but the difference in return value is fairly modest: I'd like to see a variation of mkstemp() that returns a file object inste

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread skip
Guido> I'd be much happier if there was a standard API in tempfile.py Guido> that did that for you, so you wouldn't have to understand Guido> fdopen(). That can be arranged: http://bugs.python.org/issue2717 Guido> (Your example is wrong BTW, the open mode would have to be

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread Guido van Rossum
I'd be much happier if there was a standard API in tempfile.py that did that for you, so you wouldn't have to understand fdopen(). (Your example is wrong BTW, the open mode would have to be something like 'rb+' or 'wb+'.) On Mon, Apr 28, 2008 at 4:35 PM, <[EMAIL PROTECTED]> wrote: > > Guido>

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread skip
Guido> IMO mkstemp() is a major pain because you have to use raw file Guido> descriptors on the return value. I'd much rather recommend Guido> [Named]TemporaryFile which return streams. Why not: fd, fname = tempfile.mkstemp() f = os.fdopen(fd) Seems fairly straightforward to

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread Guido van Rossum
IMO mkstemp() is a major pain because you have to use raw file descriptors on the return value. I'd much rather recommend [Named]TemporaryFile which return streams. On Mon, Apr 28, 2008 at 4:17 PM, <[EMAIL PROTECTED]> wrote: > > Guido> Have we documented the alternatives well enough? > > I s

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread skip
Guido> Have we documented the alternatives well enough? I suppose we could document explicitly how to use mkstemp() in place of mktemp(), but the difference in return value is fairly modest: >>> tempfile.mktemp() '/var/folders/5q/5qTPn6xq2RaWqk+1Ytw3-U+++TI/-Tmp-/tmpV_5OLi' >>>

Re: [Python-Dev] Warn about mktemp once again?

2008-04-28 Thread Guido van Rossum
Have we documented the alternatives well enough? In most cases NamedTemporaryFile will work, but sometimes you will have to create a directory and pick names therein. Doing that so that it will always be cleaned up properly is a bit of a trick, involving an isdir() check and a shutil.rmtree() call.

Re: [Python-Dev] enhanced ioctl?

2008-04-28 Thread Neal Becker
Benjamin Peterson wrote: > On Mon, Apr 28, 2008 at 7:02 AM, Neal Becker <[EMAIL PROTECTED]> wrote: >> IIUC, current ioctl is not capable of handling arbitrary argument types. >> This code will allow any arg type (such as structures with pointers to >> embedded structures). > > Please submit thi

Re: [Python-Dev] enhanced ioctl?

2008-04-28 Thread Benjamin Peterson
On Mon, Apr 28, 2008 at 7:02 AM, Neal Becker <[EMAIL PROTECTED]> wrote: > IIUC, current ioctl is not capable of handling arbitrary argument types. > This code will allow any arg type (such as structures with pointers to > embedded structures). Please submit this patch to the tracker. -- Cheer

[Python-Dev] enhanced ioctl?

2008-04-28 Thread Neal Becker
IIUC, current ioctl is not capable of handling arbitrary argument types. This code will allow any arg type (such as structures with pointers to embedded structures). The code for _IOC is taken from linux and might not be portable. from ctypes import * libc = CDLL ('/lib/libc.so.6') #print libc.i

Re: [Python-Dev] Dealing with a desired change to warnings.showwarning()

2008-04-28 Thread Antoine Pitrou
Brett Cannon python.org> writes: > As http://bugs.python.org/issue2705 points out, though, since the > function has been documented as being allowed to be overridden, this > potentially breaks existing showwarning() implementations. That means > something needs to change. > > One option is to int