mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
More proper closing of files
This commit is contained in:
parent
73315e9200
commit
92f60ed82a
7 changed files with 82 additions and 57 deletions
|
@ -204,11 +204,17 @@ def open_file(path):
|
|||
|
||||
def create_package(source):
|
||||
ofi = None
|
||||
for line in source.splitlines():
|
||||
if line.startswith(" ") or line.startswith("\t"):
|
||||
ofi.write(line.strip() + "\n")
|
||||
else:
|
||||
ofi = open_file(os.path.join(TEST_DIR, line.strip()))
|
||||
try:
|
||||
for line in source.splitlines():
|
||||
if line.startswith(" ") or line.startswith("\t"):
|
||||
ofi.write(line.strip() + "\n")
|
||||
else:
|
||||
if ofi:
|
||||
ofi.close()
|
||||
ofi = open_file(os.path.join(TEST_DIR, line.strip()))
|
||||
finally:
|
||||
if ofi:
|
||||
ofi.close()
|
||||
|
||||
class ModuleFinderTest(unittest.TestCase):
|
||||
def _do_test(self, info, report=False):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue