NamedTemporaryFile and mode a+rwx

christophe.delarue at gmail.com christophe.delarue at gmail.com
Mon Oct 3 09:57:59 EDT 2005


Hi,

I'd like to create a temporaty shell script. Therefore I use tempfile
with NamedTemporaryFile. The problem is that the _mkstemp_inner create
the file using 06000 code. Then the fdopen is called, but the stat of
the file does not change to executable.

Why the fdopen does not modify the mode of the file ?

Without the executable flag, this could not be understood as an
executable file.

Thanks.

the trace :

>>> t=tempfile.NamedTemporaryFile(mode="a+rwx")
>>> print t.name
/tmp/tmp5wwa9K
>>> print t.mode
a+rwx
>>> os.system("ls -l " + t.name)
-rw-------   1 myLogin         0 Oct  3 15:30 /tmp/tmp5wwa9K
>>> os.system("stat " + t.name)
  File: `/tmp/tmp5wwa9K'
  Size: 0         	Blocks: 0          IO Block: 8192   regular empty
file
Device: 2h/2d	Inode: 8593614     Links: 1
Access: (0600/-rw-------)  Uid: (10373/ numerix)   Gid: ( 1102/
rms)
Access: 2005-10-03 15:30:38.000000000 +0200
Modify: 2005-10-03 15:30:38.000000000 +0200
Change: 2005-10-03 15:30:38.000000000 +0200




More information about the Python-list mailing list