Skip to content

Commit 1b45a91

Browse files
author
Kurt Yoder
authored
Merge pull request #29 from SergioRAgostinho/fd-warnings
Close file descriptor when no longer needed.
2 parents 7496011 + 2656578 commit 1b45a91

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pywavefront/parser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ class Parser(object):
4242
strict = False
4343

4444
def read_file(self, file_name):
45-
for line in open(file_name, 'r'):
46-
self.parse(line, dir=os.path.dirname(file_name))
45+
with open(file_name, 'r') as file:
46+
for line in file:
47+
self.parse(line, dir=os.path.dirname(file_name))
4748

4849
def parse(self, line, dir):
4950
"""Determine what type of line we are and dispatch

0 commit comments

Comments
 (0)