Commit 67a8a4047bac9e618da102e3194b6812c8f9ce85

Authored by neonknight
1 parent 6870f158

fix py3 incompatibility

Showing 1 changed file with 6 additions and 3 deletions
oletools/olevba.py
... ... @@ -246,7 +246,10 @@ import sys
246 246 import os
247 247 import logging
248 248 import struct
249   -import cStringIO
  249 +try:
  250 + from cStringIO import StringIO
  251 +except ImportError:
  252 + from io import StringIO
250 253 import math
251 254 import zipfile
252 255 import re
... ... @@ -1352,7 +1355,7 @@ def _extract_vba(ole, vba_root, project_path, dir_path, relaxed=False):
1352 1355 else:
1353 1356 raise UnexpectedDataError(dir_path, name, expected, value)
1354 1357  
1355   - dir_stream = cStringIO.StringIO(decompress_stream(dir_compressed))
  1358 + dir_stream = StringIO(decompress_stream(dir_compressed))
1356 1359  
1357 1360 # PROJECTSYSKIND Record
1358 1361 projectsyskind_id = struct.unpack("<H", dir_stream.read(2))[0]
... ... @@ -2309,7 +2312,7 @@ class VBA_Parser(object):
2309 2312 _file = filename
2310 2313 else:
2311 2314 # file already read in memory, make it a file-like object for zipfile:
2312   - _file = cStringIO.StringIO(data)
  2315 + _file = StringIO(data)
2313 2316 #self.file = _file
2314 2317 self.ole_file = None
2315 2318 self.ole_subfiles = []
... ...