Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
filename = None
while context >= 0:
frame = frame.f_back
filename = inspect.getsourcefile(frame)
if filename is not None:
context -= 1
filename = os.path.abspath(filename)
if frame.f_globals.get('__name__') != '__main__':
if PY3 and self._treetrace_hidden_with_stmt.__name__ not in frame.f_globals:
raise RuntimeError(
'To trace an imported module, you must import birdseye before '
'importing that module.')
return
lines = read_source_file(filename).splitlines()
lines[:frame.f_lineno] = [''] * frame.f_lineno
source = '\n'.join(lines)
self.exec_string(source, filename, frame.f_globals, frame.f_locals, deep)
sys.exit(0)
def read():
return read_source_file(filename).strip()
pass
if is_lambda(func):
raise ValueError('You cannot trace lambdas')
filename = inspect.getsourcefile(func) # type: str
if is_ipython_cell(filename):
# noinspection PyPackageRequirements
from IPython import get_ipython
import linecache
flags = get_ipython().compile.flags
source = ''.join(linecache.cache[filename][2])
else:
source = read_source_file(filename)
flags = 0
# We compile the entire file instead of just the function source
# because it can contain context which affects the function code,
# e.g. enclosing functions and classes or __future__ imports
traced_file = self.compile(source, filename, flags)
if func.__dict__:
raise ValueError('The birdseye decorator must be applied first, '
'at the bottom of the list.')
# Then we have to recursively search through the newly compiled
# code to find the code we actually want corresponding to this function
code_options = [] # type: List[CodeType]
def find_code(root_code):
filename = None
while context >= 0:
frame = frame.f_back
filename = inspect.getsourcefile(frame)
if filename is not None:
context -= 1
filename = os.path.abspath(filename)
if frame.f_globals.get('__name__') != '__main__':
if PY3 and self._treetrace_hidden_with_stmt.__name__ not in frame.f_globals:
raise RuntimeError(
'To trace an imported module, you must import birdseye before '
'importing that module.')
return
lines = read_source_file(filename).splitlines()
lines[:frame.f_lineno] = [''] * frame.f_lineno
source = '\n'.join(lines)
self.exec_string(source, filename, frame.f_globals, frame.f_locals, deep)
sys.exit(0)
pass
if is_lambda(func):
raise ValueError('You cannot trace lambdas')
filename = inspect.getsourcefile(func) # type: str
if is_ipython_cell(filename):
# noinspection PyPackageRequirements
from IPython import get_ipython
import linecache
flags = get_ipython().compile.flags
source = ''.join(linecache.cache[filename][2])
else:
source = read_source_file(filename)
flags = 0
# We compile the entire file instead of just the function source
# because it can contain context which affects the function code,
# e.g. enclosing functions and classes or __future__ imports
traced_file = self.compile(source, filename, flags)
if func.__dict__:
raise ValueError('The birdseye decorator must be applied first, '
'at the bottom of the list.')
# Then we have to recursively search through the newly compiled
# code to find the code we actually want corresponding to this function
code_options = [] # type: List[CodeType]
def find_code(root_code):