summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Campeas <devnull@localhost>2009-09-09 11:17:48 +0200
committerAurelien Campeas <devnull@localhost>2009-09-09 11:17:48 +0200
commitcb6937f54b610436e1e0d2c74fe82d142834e726 (patch)
treee0b520abce679f00cfd9ca4c66958fd5fbde2623
parentf819e856e6bd9e09797c2480c310c7e5c51b0f23 (diff)
downloadlogilab-common-cb6937f54b610436e1e0d2c74fe82d142834e726.tar.gz
fix file descriptor leak with an incorrect use of mkstemp
-rw-r--r--graph.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/graph.py b/graph.py
index 32deb0b..c81887e 100644
--- a/graph.py
+++ b/graph.py
@@ -82,12 +82,15 @@ class DotBackend:
storedir, basename, target = target_info_from_filename(outputfile)
if target != "dot":
pdot, dot_sourcepath = tempfile.mkstemp(".dot", name)
+ os.close(pdot)
else:
dot_sourcepath = osp.join(storedir, dotfile)
else:
target = 'png'
pdot, dot_sourcepath = tempfile.mkstemp(".dot", name)
ppng, outputfile = tempfile.mkstemp(".png", name)
+ os.close(pdot)
+ os.close(ppng)
pdot = open(dot_sourcepath,'w')
if isinstance(self.source, unicode):
pdot.write(self.source.encode('UTF8'))
@@ -97,11 +100,7 @@ class DotBackend:
if target != 'dot':
subprocess.call('%s -T%s %s -o%s' % (self.renderer, target,
dot_sourcepath, outputfile), shell=True)
- try:
- os.unlink(dot_sourcepath)
- except OSError:
- if sys.platform != 'win32':
- raise
+ os.unlink(dot_sourcepath)
return outputfile
def emit(self, line):