Commit 5ec9c14937f0cc1580584e953a3da138ab9011e3
1 parent
8e1d03d7
olevba: define unicode=str for Python 3 (issue #106)
Showing
1 changed file
with
3 additions
and
1 deletions
oletools/olevba.py
| ... | ... | @@ -342,6 +342,8 @@ else: |
| 342 | 342 | xrange = range |
| 343 | 343 | # unichr does not exist anymore, only chr: |
| 344 | 344 | unichr = chr |
| 345 | + # json2ascii also needs "unicode": | |
| 346 | + unicode = str | |
| 345 | 347 | from functools import reduce |
| 346 | 348 | #: Default string encoding for the olevba API |
| 347 | 349 | DEFAULT_API_ENCODING = None # on Python 3: None (unicode) |
| ... | ... | @@ -2258,7 +2260,7 @@ def json2ascii(json_obj, encoding='utf8', errors='replace'): |
| 2258 | 2260 | pass |
| 2259 | 2261 | elif isinstance(json_obj, (bool, int, float)): |
| 2260 | 2262 | pass |
| 2261 | - elif isinstance(json_obj, str): | |
| 2263 | + elif isinstance(json_obj, bytes): | |
| 2262 | 2264 | # de-code and re-encode |
| 2263 | 2265 | dencoded = json_obj.decode(encoding, errors).encode(encoding, errors) |
| 2264 | 2266 | if dencoded != json_obj: | ... | ... |