diff --git a/oletools/ezhexviewer.py b/oletools/ezhexviewer.py index 142d547e..b168a118 100644 --- a/oletools/ezhexviewer.py +++ b/oletools/ezhexviewer.py @@ -132,6 +132,7 @@ def hexdump3(src, length=8, startindex=0): startindex: index of 1st byte. """ result=[] + # pylint: disable-next=possibly-used-before-assignment for i in xrange(0, len(src), length): s = src[i:i+length] hexa = ' '.join(["%02X" % xord(x) for x in s]) diff --git a/oletools/msodde.py b/oletools/msodde.py index 49fa42c4..8c4c6564 100644 --- a/oletools/msodde.py +++ b/oletools/msodde.py @@ -388,6 +388,7 @@ def process_doc_stream(stream): # appending a raw byte to a unicode string here. Not clean but # all we do later is check for the ascii-sequence 'DDE' later... elif char == 0: # may be a high-byte of a 2-byte codec + # pylint: disable-next=possibly-used-before-assignment field_contents += unichr(char) elif char in (10, 13): field_contents += u'\n' diff --git a/oletools/oleobj.py b/oletools/oleobj.py index c694fc25..e334477c 100644 --- a/oletools/oleobj.py +++ b/oletools/oleobj.py @@ -332,6 +332,7 @@ def read_zero_terminated_string(data, index): """ if index is None: result = bytearray() + # pylint: disable-next=possibly-used-before-assignment for _ in xrange(STR_MAX_LEN): char = ord(data.read(1)) # need ord() for py3 if char == 0: diff --git a/oletools/olevba.py b/oletools/olevba.py index 4bb63f66..a44bb777 100644 --- a/oletools/olevba.py +++ b/oletools/olevba.py @@ -1050,6 +1050,7 @@ def vba_chr_tostr(t): else: # unicode character # Note: this distinction is only needed for Python 2 + # pylint: disable-next=possibly-used-before-assignment return VbaExpressionString(unichr(i).encode('utf-8', 'backslashreplace')) except ValueError: log.exception('ERROR: incorrect parameter value for chr(): %r' % i) @@ -1165,6 +1166,7 @@ def subtract_ints_list(tokens): # extract argument from the tokens: # expected to be a tuple containing a list of integers such as [a,'&',b,'&',c,...] integers = tokens[0][::2] + # pylint: disable-next=possibly-used-before-assignment return reduce(lambda x,y:x-y, integers) @@ -1407,6 +1409,7 @@ def decompress_stream(compressed_container): # copy tokens (reference to a previous literal token) flag_byte = compressed_container[compressed_current] compressed_current += 1 + # pylint: disable-next=possibly-used-before-assignment for bit_index in xrange(0, 8): # log.debug('bit_index=%d / compressed_current=%d / compressed_end=%d' % (bit_index, compressed_current, compressed_end)) if compressed_current >= compressed_end: @@ -2434,6 +2437,7 @@ def json2ascii(json_obj, encoding='utf8', errors='replace'): else: # on Python 3, just keep Unicode strings as-is: return json_obj + # pylint: disable-next=possibly-used-before-assignment elif isinstance(json_obj, unicode) and PYTHON2: # On Python 2, encode unicode to bytes: json_obj_bytes = json_obj.encode(encoding, errors)