def _compact_stack_trace(op):
    """Returns a traceback for `op` with common file prefixes stripped."""
    compact_traces = []
    common_prefix = error_interpolation.traceback_files_common_prefix([[op]])
    # TODO(slebedev): switch to .filename etc once 2.X support is dropped.
    for filename, lineno, name, line in op.traceback:
        if filename.startswith(common_prefix):
            filename = filename[len(common_prefix):]
        compact_traces.append((filename, lineno, name, line))
    return compact_traces
Ejemplo n.º 2
0
def _compact_stack_trace(op):
  """Returns a traceback for `op` with common file prefixes stripped."""
  compact_traces = []
  common_prefix = error_interpolation.traceback_files_common_prefix([[op]])
  for frame in op.traceback:
    filename = frame.filename
    if filename.startswith(common_prefix):
      filename = filename[len(common_prefix):]
    compact_traces.append((filename, frame.lineno, frame.name, frame.line))
  return compact_traces
Ejemplo n.º 3
0
def _compact_stack_trace(op):
  """Returns a traceback for `op` with common file prefixes stripped."""
  compact_traces = []
  common_prefix = error_interpolation.traceback_files_common_prefix([[op]])
  for frame in op.traceback:
    frame = list(frame)
    filename = frame[tf_stack.TB_FILENAME]
    if filename.startswith(common_prefix):
      filename = filename[len(common_prefix):]
      frame[tf_stack.TB_FILENAME] = filename
    compact_traces.append(tuple(frame))
  return compact_traces
Ejemplo n.º 4
0
def _compact_stack_trace(op):
  """Returns a traceback for `op` with common file prefixes stripped."""
  compact_traces = []
  common_prefix = error_interpolation.traceback_files_common_prefix([[op]])
  for frame in op.traceback:
    frame = list(frame)
    filename = frame[tf_stack.TB_FILENAME]
    if filename.startswith(common_prefix):
      filename = filename[len(common_prefix):]
      frame[tf_stack.TB_FILENAME] = filename
    compact_traces.append(tuple(frame))
  return compact_traces
Ejemplo n.º 5
0
def _compact_stack_trace(op):
  """Returns a traceback for `op` with common file prefixes stripped."""
  compact_traces = []
  common_prefix = error_interpolation.traceback_files_common_prefix([[op]])
  # pylint: disable=protected-access
  tf_traceback = tf_stack.convert_stack(op._traceback)
  # pylint: enable=protected-access
  for frame in tf_traceback:
    frame = list(frame)
    filename = frame[tf_stack.TB_FILENAME]
    if filename.startswith(common_prefix):
      filename = filename[len(common_prefix):]
      frame[tf_stack.TB_FILENAME] = filename
    compact_traces.append(tuple(frame))
  return compact_traces