Skip to content

Commit

Permalink
Merge pull request #418 from j-t-1/context
Browse files Browse the repository at this point in the history
Use with statement to write to file
  • Loading branch information
erocarrera authored Aug 26, 2024
2 parents 7368b0c + fee84a7 commit de28d34
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3521,10 +3521,8 @@ def write(self, filename=None):
if not filename:
return new_file_data

f = open(filename, "wb+")
f.write(new_file_data)
f.close()
return
with open(filename, "wb+") as f:
f.write(new_file_data)

def parse_sections(self, offset):
"""Fetch the PE file sections.
Expand Down

0 comments on commit de28d34

Please sign in to comment.