[svn r45901] Do not use os.tmpfile() as it will fail on Windows unless You are Administrator.

--HG--
branch : trunk
This commit is contained in:
ac 2007-08-21 20:39:21 +02:00
parent e722cb2db7
commit 643289e013
1 changed files with 3 additions and 2 deletions

View File

@ -2,6 +2,7 @@
import os import os
import sys import sys
import py import py
import tempfile
class FDCapture: class FDCapture:
""" Capture IO to/from a given os-level filedescriptor. """ """ Capture IO to/from a given os-level filedescriptor. """
@ -41,7 +42,7 @@ class FDCapture:
def maketmpfile(self): def maketmpfile(self):
""" create a temporary file """ create a temporary file
""" """
f = os.tmpfile() f = tempfile.TemporaryFile()
newf = py.io.dupfile(f) newf = py.io.dupfile(f)
f.close() f.close()
return newf return newf
@ -49,7 +50,7 @@ class FDCapture:
def writeorg(self, str): def writeorg(self, str):
""" write a string to the original file descriptor """ write a string to the original file descriptor
""" """
tempfp = os.tmpfile() tempfp = tempfile.TemporaryFile()
try: try:
os.dup2(self._savefd, tempfp.fileno()) os.dup2(self._savefd, tempfp.fileno())
tempfp.write(str) tempfp.write(str)