From 65211cc7e61940792424333e3ec3d74b1be4ae6b Mon Sep 17 00:00:00 2001 From: j-t-1 <120829237+j-t-1@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:03:58 +0000 Subject: [PATCH] Format using f-strings --- pefile.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pefile.py b/pefile.py index f804678..b75ab78 100644 --- a/pefile.py +++ b/pefile.py @@ -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 @@ -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 @@ -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: