@@ -332,30 +332,6 @@ def _safe_import_hook(self, name, caller, fromlist, level=-1):
332332 fullname = name + "." + sub
333333 self ._add_badmodule (fullname , caller )
334334
335- def scan_opcodes (self , co ,
336- unpack = struct .unpack ):
337- # Scan the code, and yield 'interesting' opcode combinations
338- # Version for Python 2.4 and older
339- code = co .co_code
340- names = co .co_names
341- consts = co .co_consts
342- while code :
343- c = code [0 ]
344- if c in STORE_OPS :
345- oparg , = unpack ('<H' , code [1 :3 ])
346- yield "store" , (names [oparg ],)
347- code = code [3 :]
348- continue
349- if c == LOAD_CONST and code [3 ] == IMPORT_NAME :
350- oparg_1 , oparg_2 = unpack ('<xHxH' , code [:6 ])
351- yield "import" , (consts [oparg_1 ], names [oparg_2 ])
352- code = code [6 :]
353- continue
354- if c >= HAVE_ARGUMENT :
355- code = code [3 :]
356- else :
357- code = code [1 :]
358-
359335 def scan_opcodes_25 (self , co ,
360336 unpack = struct .unpack ):
361337 # Scan the code, and yield 'interesting' opcode combinations
@@ -387,10 +363,7 @@ def scan_opcodes_25(self, co,
387363
388364 def scan_code (self , co , m ):
389365 code = co .co_code
390- if sys .version_info >= (2 , 5 ):
391- scanner = self .scan_opcodes_25
392- else :
393- scanner = self .scan_opcodes
366+ scanner = self .scan_opcodes_25
394367 for what , args in scanner (co ):
395368 if what == "store" :
396369 name , = args
0 commit comments