Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for l in lines:
if hasattr(l, "decode"):
decoded_lines.append(l.decode(source_enc))
else:
decoded_lines.append(l)
self.source[:] = format_source(self,
decoded_lines, set(breakpoints))
except:
from traceback import format_exception
import sys
self.message("Could not load source file '%s':\n\n%s" % (
fname, "".join(format_exception(*sys.exc_info()))),
title="Source Code Load Error")
self.source[:] = [SourceLine(self,
"Error while loading '%s'." % fname)]
self.shown_file = fname
self.current_line = None
def shipout_line():
result.append(
SourceLine(debugger_ui,
subself.current_line,
lineno_format % subself.lineno,
subself.current_attr,
has_breakpoint=subself.lineno in breakpoints))
subself.current_line = ""
subself.current_attr = []
subself.lineno += 1
def set_current_file(self, fname):
from pudb.source_view import SourceLine, format_source
fname = self.debugger.canonic(fname)
if self.shown_file != fname:
if fname == "":
self.source[:] = [SourceLine(self, fname)]
else:
breakpoints = self.debugger.get_file_breaks(fname)
try:
from linecache import getlines
lines = getlines(fname)
from pudb.lowlevel import detect_encoding
source_enc, _ = detect_encoding(iter(lines).next)
decoded_lines = []
for l in lines:
if hasattr(l, "decode"):
decoded_lines.append(l.decode(source_enc))
else:
decoded_lines.append(l)
def get_lines(self, debugger_ui):
from pudb.source_view import SourceLine
return [
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, "If this is generated code and you would "
"like the source code to show up here,"),
SourceLine(debugger_ui, "add it to linecache.cache, like"),
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, " import linecache"),
SourceLine(debugger_ui, " linecache.cache[filename] = "
"(size, mtime, lines, fullname)"),
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, "You can also set the attribute "
"_MODULE_SOURCE_CODE in the module in which this function"),
SourceLine(debugger_ui, "was compiled to a string containing "
"the code."),
breakpoints = [lineno for lineno in breakpoints if
any(bp.enabled
for bp in debugger_ui.debugger.get_breaks(self.file_name, lineno))]
breakpoints += [i for f, i in debugger_ui.debugger.set_traces if f
== self.file_name and debugger_ui.debugger.set_traces[f, i]]
try:
from linecache import getlines
lines = getlines(self.file_name)
return format_source(
debugger_ui, list(decode_lines(lines)), set(breakpoints))
except Exception:
from pudb.lowlevel import format_exception
debugger_ui.message("Could not load source file '%s':\n\n%s" % (
self.file_name, "".join(format_exception(sys.exc_info()))),
title="Source Code Load Error")
return [SourceLine(debugger_ui,
"Error while loading '%s'." % self.file_name)]
def get_lines(self, debugger_ui):
from pudb.source_view import SourceLine
return [
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, "If this is generated code and you would "
"like the source code to show up here,"),
SourceLine(debugger_ui, "add it to linecache.cache, like"),
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, " import linecache"),
SourceLine(debugger_ui, " linecache.cache[filename] = "
"(size, mtime, lines, fullname)"),
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, "You can also set the attribute "
"_MODULE_SOURCE_CODE in the module in which this function"),
SourceLine(debugger_ui, "was compiled to a string containing "
"the code."),
def get_lines(self, debugger_ui):
from pudb.source_view import SourceLine
return [
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, "If this is generated code and you would "
"like the source code to show up here,"),
SourceLine(debugger_ui, "add it to linecache.cache, like"),
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, " import linecache"),
SourceLine(debugger_ui, " linecache.cache[filename] = "
"(size, mtime, lines, fullname)"),
SourceLine(debugger_ui, ""),
SourceLine(debugger_ui, "You can also set the attribute "
"_MODULE_SOURCE_CODE in the module in which this function"),
SourceLine(debugger_ui, "was compiled to a string containing "
"the code."),