diff --git a/pyinstxtractor.py b/pyinstxtractor.py index 544631e..678db61 100644 --- a/pyinstxtractor.py +++ b/pyinstxtractor.py @@ -92,10 +92,15 @@ import marshal import zlib import sys -import imp import types from uuid import uuid4 as uniquename +try: + import importlib.util + PYC_MAGIC=importlib.util.MAGIC_NUMBER +except ImportError: + import imp + PYC_MAGIC=imp.get_magic() class CTOCEntry: def __init__(self, position, cmprsdDataSize, uncmprsdDataSize, cmprsFlag, typeCmprsData, name): @@ -274,7 +279,7 @@ def _extractPyz(self, name): pycHeader = f.read(4) # Python magic value - if imp.get_magic() != pycHeader: + if PYC_MAGIC != pycHeader: print('[!] Warning: The script is running in a different python version than the one used to build the executable') print(' Run this script in Python{0} to prevent extraction errors(if any) during unmarshalling'.format(self.pyver))