Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format using f-strings #446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading