From 4a968da46a39a83869f7a2f99e04ce98a41bdbfd Mon Sep 17 00:00:00 2001 From: defaultuser8848 <158047456+defaultuser8848@users.noreply.github.com> Date: Thu, 15 Aug 2024 22:33:35 +0800 Subject: [PATCH] Update pyinstxtractor.py To resolve compatibility issues --- pyinstxtractor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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))