gh-112730: use keyword only argument for colorize by methane · Pull Request #118086 · python/cpython
def print_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, \ file=None, chain=True, **kwargs): def print_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, file=None, chain=True, *, colorize=False): """Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
This differs from print_tb() in the following ways: (1) if
def format_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, \ def format_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, chain=True): """Format a stack trace and the exception information.
def format_frame_summary(self, frame_summary, **kwargs): def format_frame_summary(self, frame_summary, *, colorize=False): """Format the lines for a single FrameSummary.
Returns a string representing one frame involved in the stack. This gets called for every frame to be printed in the stack summary. """ colorize = kwargs.get("colorize", False) row = [] filename = frame_summary.filename if frame_summary.filename.startswith("<stdin>-"):
return ''.join(row)
def format(self, **kwargs): def format(self, *, colorize=False): """Format the stack ready for printing.
Returns a list of strings ready for printing. Each string in the
def format_exception_only(self, *, show_group=False, _depth=0, **kwargs): def format_exception_only(self, *, show_group=False, _depth=0, colorize=False): """Format the exception part of the traceback.
The return value is a generator of strings, each ending in a newline.
indent = 3 * _depth * ' ' if not self._have_exc_type: yield indent + _format_final_exc_line(None, self._str, colorize=colorize)
def _format_syntax_error(self, stype, **kwargs): def _format_syntax_error(self, stype, *, colorize=False): """Format SyntaxError exceptions (internal helper).""" # Show exactly where the problem was found. colorize = kwargs.get("colorize", False) filename_suffix = '' if self.lineno is not None: if colorize:
def format(self, *, chain=True, _ctx=None, **kwargs): def format(self, *, chain=True, _ctx=None, colorize=False): """Format the exception.
If chain is not *True*, *__cause__* and *__context__* will not be formatted.
def print(self, *, file=None, chain=True, **kwargs): def print(self, *, file=None, chain=True, colorize=False): """Print the result of self.format(chain=chain) to 'file'.""" colorize = kwargs.get("colorize", False) if file is None: file = sys.stderr for line in self.format(chain=chain, colorize=colorize):