Skip to content

Commit 0264285

Browse files
committed
Fix file handle leak when building from file
1 parent 9e29ad0 commit 0264285

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

aiohttp_swagger/helpers/builders.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ def nesteddict2yaml(d, indent=10, result=""):
155155

156156

157157
def load_doc_from_yaml_file(doc_path: str):
158-
loaded_yaml = yaml.load(open(doc_path, "r", encoding="utf-8").read(), Loader=yaml.FullLoader)
158+
with open(doc_path, "r", encoding="utf-8") as f:
159+
loaded_yaml = yaml.load(f.read(), Loader=yaml.FullLoader)
159160
return json.dumps(loaded_yaml)
160161

161162

0 commit comments

Comments
 (0)