Skip to content

Commit

Permalink
Increase readability and consistency
Browse files Browse the repository at this point in the history
Remove a superfluous pass statement.
One refactor to a chain comparison operator.
Use args and kwargs throughout.
  • Loading branch information
j-t-1 authored Jun 25, 2024
1 parent 7368b0c commit 457bf07
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ def parse_strings(data, counter, l):
l[counter] = data[i : i + len_ * 2].decode("utf-16le")
except UnicodeDecodeError:
error_count += 1
pass
if error_count >= 3:
break
i += len_ * 2
Expand Down Expand Up @@ -1129,16 +1128,16 @@ def dump_dict(self):
class SectionStructure(Structure):
"""Convenience section handling class."""

def __init__(self, *argl, **argd):
if "pe" in argd:
self.pe = argd["pe"]
del argd["pe"]
def __init__(self, *args, **kwargs):
if "pe" in kwargs:
self.pe = kwargs["pe"]
del kwargs["pe"]

self.PointerToRawData = None
self.VirtualAddress = None
self.SizeOfRawData = None
self.Misc_VirtualSize = None
Structure.__init__(self, *argl, **argd)
Structure.__init__(self, *args, **kwargs)
self.PointerToRawData_adj = None
self.VirtualAddress_adj = None
self.section_min_addr = None
Expand Down Expand Up @@ -1523,9 +1522,9 @@ def _pack_bitfield_attributes(self):
class DataContainer:
"""Generic data container."""

def __init__(self, **args):
def __init__(self, **kwargs):
bare_setattr = super().__setattr__
for key, value in args.items():
for key, value in kwargs.items():
bare_setattr(key, value)


Expand Down Expand Up @@ -5620,7 +5619,7 @@ def normalize_import_va(self, va):

# Try to avoid bogus VAs, which are out of the image.
# This also filters out entries that are zero
if begin_of_image <= va and va < end_of_image:
if begin_of_image <= va < end_of_image:
va -= begin_of_image
return va

Expand Down

0 comments on commit 457bf07

Please sign in to comment.