Skip to content

Commit

Permalink
Format using f-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
j-t-1 authored Dec 5, 2024
1 parent 4b3b1e2 commit 65211cc
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2978,9 +2978,8 @@ def __unpack_data__(self, format, data, file_offset):
structure.__unpack__(data)
except PEFormatError as err:
self.__warnings.append(
'Corrupt header "{0}" at file offset {1}. Exception: {2}'.format(
format[0], file_offset, err
)
f'Corrupt header "{format[0]}" at file offset {file_offset}. '
f'Exception: {err}'.format
)
return None

Expand All @@ -3000,9 +2999,8 @@ def __unpack_data_with_bitfields__(self, format, data, file_offset):
structure.__unpack__(data)
except PEFormatError as err:
self.__warnings.append(
'Corrupt header "{0}" at file offset {1}. Exception: {2}'.format(
format[0], file_offset, err
)
f'Corrupt header "{format[0]}" at file offset {file_offset}. '
f'Exception: {err}'
)
return None

Expand Down Expand Up @@ -3033,10 +3031,10 @@ def __parse__(self, fname, data, fast_load):
self.__data__ = mmap.mmap(self.fileno, 0, access=mmap.ACCESS_READ)
self.__from_file = True
except IOError as excp:
exception_msg = "{0}".format(excp)
exception_msg = f"{excp}"
exception_msg = exception_msg and (": %s" % exception_msg)
raise Exception(
"Unable to access file '{0}'{1}".format(fname, exception_msg)
f"Unable to access file '{fname}'{exception_msg}"
)
finally:
if fd is not None:
Expand Down

0 comments on commit 65211cc

Please sign in to comment.