Skip to content

Commit c4f8ed5

Browse files
Rob AnkenyCapirca Team
authored andcommitted
Copybara import of the project:
-- 56fc1d5 by Natalia Maximo <[email protected]>: Ensured file handlers are closed appropriately in capirca.lib.naming PiperOrigin-RevId: 319815558
1 parent 211b7f8 commit c4f8ed5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

capirca/lib/naming.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ def __init__(self, naming_dir=None, naming_file=None, naming_type=None):
136136
re.IGNORECASE|re.DOTALL)
137137
if naming_file and naming_type:
138138
filename = os.path.sep.join([naming_dir, naming_file])
139-
with open(filename, 'r') as file_handle:
140-
self._ParseFile(file_handle, naming_type)
139+
file_handle = open(filename, 'r')
140+
self._ParseFile(file_handle, naming_type)
141141
elif naming_dir:
142142
self._Parse(naming_dir, 'services')
143143
self._CheckUnseen('services')
@@ -525,8 +525,8 @@ def _Parse(self, defdirectory, def_type):
525525

526526
for current_file in file_names:
527527
try:
528-
with open(current_file, 'r') as file_handle:
529-
self._ParseFile(file_handle, def_type)
528+
file_handle = open(current_file, 'r')
529+
self._ParseFile(file_handle, def_type)
530530
except IOError as error_info:
531531
raise NoDefinitionsError('%s' % error_info)
532532

0 commit comments

Comments
 (0)