Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_code(self, code, nodes):
linestarts = dict(dis.findlinestarts(code))
instructions = get_instructions(code)
lineno = None
for inst in instructions:
if time.time() - self.start_time > 45 * 60:
# Avoid travis time limit of 50 minutes
raise TimeOut
lineno = linestarts.get(inst.offset, lineno)
if not inst.opname.startswith((
'BINARY_', 'UNARY_', 'LOAD_ATTR', 'LOAD_METHOD', 'LOOKUP_METHOD',
'SLICE+', 'COMPARE_OP', 'CALL_', 'IS_OP', 'CONTAINS_OP',
)):
continue
frame = C()
frame.f_lasti = inst.offset
frame.f_code = code
frame.f_globals = globals()