11#
2- # (C) Copyright 2015-2018, 2020-2021, 2023 by Rocky Bernstein
2+ # (C) Copyright 2015-2018, 2020-2021, 2023, 2025 by Rocky Bernstein
33# (C) Copyright 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
44#
55# This program is free software: you can redistribute it and/or modify
1818byte-code verification
1919"""
2020
21- from __future__ import print_function
21+ import operator
22+ import sys
23+ from functools import reduce
24+ from subprocess import call
2225
23- import operator , sys
2426import xdis .std as dis
25- from subprocess import call
27+ from xdis import PYTHON_MAGIC_INT , iscode , load_file , load_module , pretty_code_flags
28+ from xdis .version_info import PythonImplementation
2629
2730import uncompyle6
2831from uncompyle6 .scanner import Token as ScannerToken , get_scanner
29- from xdis import iscode , load_file , load_module , pretty_code_flags , PYTHON_MAGIC_INT
3032
3133truediv = operator .truediv
32- from functools import reduce
3334
3435
3536def code_equal (a , b ):
@@ -485,9 +486,10 @@ def compare_code_with_srcfile(pyc_filename, src_filename, verify):
485486 timestamp ,
486487 magic_int ,
487488 code_obj1 ,
488- is_pypy ,
489+ python_implementation ,
489490 source_size ,
490491 sip_hash ,
492+ _ ,
491493 ) = load_module (pyc_filename )
492494 if magic_int != PYTHON_MAGIC_INT :
493495 msg = (
@@ -500,6 +502,7 @@ def compare_code_with_srcfile(pyc_filename, src_filename, verify):
500502 except SyntaxError as e :
501503 # src_filename can be the first of a group sometimes
502504 return str (e ).replace (src_filename , pyc_filename )
505+ is_pypy = python_impementation is PythonImplementation .PyPy
503506 cmp_code_objects (version , is_pypy , code_obj1 , code_obj2 , verify )
504507 if verify == "verify-run" :
505508 try :
@@ -520,19 +523,22 @@ def compare_files(pyc_filename1, pyc_filename2, verify):
520523 timestamp ,
521524 magic_int1 ,
522525 code_obj1 ,
523- is_pypy ,
526+ python_implementation ,
524527 source_size ,
525528 sip_hash ,
526- ) = uncompyle6 .load_module (pyc_filename1 )
529+ _
530+ ) = load_module (pyc_filename1 )
531+ is_pypy = python_implementation is PythonImplementation .PyPy
527532 (
528533 version2 ,
529534 timestamp ,
530535 magic_int2 ,
531536 code_obj2 ,
532- is_pypy ,
537+ python_implementation ,
533538 source_size ,
534539 sip_hash ,
535- ) = uncompyle6 .load_module (pyc_filename2 )
540+ _
541+ ) = load_module (pyc_filename2 )
536542 if (magic_int1 != magic_int2 ) and verify == "verify" :
537543 verify = "weak_verify"
538544 cmp_code_objects (version1 , is_pypy , code_obj1 , code_obj2 , verify )
0 commit comments