diff options
| author | Stefan Behnel <scoder@users.berlios.de> | 2010-11-12 12:33:02 +0100 |
|---|---|---|
| committer | Stefan Behnel <scoder@users.berlios.de> | 2010-11-12 12:33:02 +0100 |
| commit | 5932f48a380cbee23259a00152924b620ade60e1 (patch) | |
| tree | 417b13c1aeed726ef736b3d682f67dd44c4cf714 /Cython/TestUtils.py | |
| parent | 5215b5b2204639b213c3d24da7813b3e51f0144d (diff) | |
| download | cython-5932f48a380cbee23259a00152924b620ade60e1.tar.gz | |
fix more dangling open files in tests
Diffstat (limited to 'Cython/TestUtils.py')
| -rw-r--r-- | Cython/TestUtils.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Cython/TestUtils.py b/Cython/TestUtils.py index 0cdcbbf0a..e01e57584 100644 --- a/Cython/TestUtils.py +++ b/Cython/TestUtils.py @@ -173,15 +173,23 @@ def unpack_source_tree(tree_file, dir=None): dir = tempfile.mkdtemp() header = [] cur_file = None - for line in open(tree_file).readlines(): + f = open(tree_file) + lines = f.readlines() + f.close() + f = None + for line in lines: if line[:5] == '#####': filename = line.strip().strip('#').strip().replace('/', os.path.sep) path = os.path.join(dir, filename) if not os.path.exists(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) + if cur_file is not None: + cur_file.close() cur_file = open(path, 'w') elif cur_file is not None: cur_file.write(line) else: header.append(line) + if cur_file is not None: + cur_file.close() return dir, ''.join(header) |
