Skip to content

Commit

Permalink
Use with statement to write to file
Browse files Browse the repository at this point in the history
  • Loading branch information
j-t-1 authored Jul 4, 2024
1 parent 7368b0c commit fee84a7
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 fee84a7

Please sign in to comment.