| commit 10: | fa077e830331 |
| parent 9: | f9c321673d70 |
| branch: | default |
Explicitly close files we opened. Jython seems to want this, or the tearDown in the unit tests can't remove the temp dir.
Changed (Δ178 bytes):
raw changeset »
cogapp/cogapp.py (8 lines added, 2 lines removed)
Up to file-list cogapp/cogapp.py:
| … | … | @@ -333,15 +333,16 @@ class Cog(Redirectable): |
333 |
333 |
|
334 |
334 |
sFileIn = fname or '' |
335 |
335 |
sFileOut = fname or '' |
336 |
fInToClose = fOutToClose = None |
|
336 |
337 |
# Convert filenames to files. |
337 |
338 |
if isinstance(fIn, types.StringTypes): |
338 |
339 |
# Open the input file. |
339 |
340 |
sFileIn = fIn |
340 |
fIn = |
|
341 |
fIn = fInToClose = open(fIn, 'r') |
|
341 |
342 |
if isinstance(fOut, types.StringTypes): |
342 |
343 |
# Open the output file. |
343 |
344 |
sFileOut = fOut |
344 |
fOut = |
|
345 |
fOut = fOutToClose = open(fOut, self.sOutputMode) |
|
345 |
346 |
|
346 |
347 |
fIn = NumberedFileReader(fIn) |
347 |
348 |
|
| … | … | @@ -479,6 +480,11 @@ class Cog(Redirectable): |
479 |
480 |
if not bSawCog and self.options.bWarnEmpty: |
480 |
481 |
self.showWarning("no cog code found in %s" % sFileIn) |
481 |
482 |
|
483 |
if fInToClose: |
|
484 |
fInToClose.close() |
|
485 |
if fOutToClose: |
|
486 |
fOutToClose.close() |
|
487 |
||
482 |
488 |
# A regex for non-empty lines, used by suffixLines. |
483 |
489 |
reNonEmptyLines = re.compile("^\s*\S+.*$", re.MULTILINE) |
484 |
490 |
