Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
frame.f_lineno = lineno
source = Source.for_frame(frame)
node = None
try:
try:
node = Source.executing(frame).node
except Exception:
if inst.opname.startswith(('COMPARE_OP', 'CALL_')):
continue
if isinstance(only(source.statements_at_line(lineno)), (ast.AugAssign, ast.Import)):
continue
raise
except Exception:
print(source.text, lineno, inst, node and ast.dump(node), code, file=sys.stderr, sep='\n')
raise
nodes[node].append((inst, frame.__dict__))
def test_file(self):
source = Source.for_frame(inspect.currentframe())
code = compile(source.text, source.filename, 'exec')
instructions = get_instructions(code)
lineno = None
for inst in instructions:
if inst.starts_line is not None:
lineno = inst.starts_line
if not inst.opname.startswith(
('BINARY_', 'UNARY_', 'LOAD_ATTR', 'LOAD_METHOD', 'LOOKUP_METHOD', 'COMPARE_OP')):
continue
frame = C()
frame.f_lasti = inst.offset
frame.f_code = code
frame.f_globals = globals()
frame.f_lineno = lineno
print(inst.opname)
assert Source.executing(frame).node is not None
def gen():
frame = current_frame()
while frame:
code = frame.f_code
filename = code.co_filename
name = Source.for_frame(frame).code_qualname(code)
yield (
filename,
frame.f_lineno,
name,
highlight_stack_frame(frame),
include_file(filename)
)
frame = frame.f_back