1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Use 'with' statements for file open/close. #1834

This commit is contained in:
dmiller
2019-12-30 06:46:34 +00:00
parent 02212559d2
commit 3e58be1551
5 changed files with 9 additions and 36 deletions

View File

@@ -817,12 +817,9 @@ class NmapParserSAX(ParserBasics, ContentHandler):
def parse_file(self, filename):
"""Parse an Nmap XML file from the named file."""
f = open(filename, "r")
try:
with open(filename, "r") as f:
self.parse(f)
self.filename = filename
finally:
f.close()
def _parse_nmaprun(self, attrs):
run_tag = "nmaprun"