Commit 9bf5e6bd0f08f66944c29eadf5fa36f22bfbe86c
Committed by
GitHub
Merge pull request #357 from neonknight/master
olevba: 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 = [] | ... | ... |