cknd/stackprinter

Incorrect docstring for `stackprinter.format`, `suppressed_exceptions_types` should be `suppressed_exceptions`

Closed this issue · 2 comments

First of all: thanks for this great package!

The docstring of stackprinter.format states, that there is a keyword argument named suppressed_exception_types.
Using that parameter results in a stackprinter crash with the following error message:

  ┆ Stackprinter failed:
  ┆   File "/.../lib/python3.11/site-packages/stackprinter/formatting.py", line 176, in format_exc_info
  ┆     whole_stack = format_stack(frameinfos, style=style,
  ┆                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ┆ TypeError: format_stack() got an unexpected keyword argument 'suppressed_exception_types'
  ┆ 
  ┆ So here is your original traceback at least:
  ┆ 
  ┆ Traceback (most recent call last):
  ┆   File "/...

stackprinter.format uses stackprinter.formatting.format_exc_info internally, which has a keyword arg suppressed_exceptions.
Using suppressed_exceptions instead of suppressed_exception_types solved the TypeError.

Here is the working Formatter Class:

class VerboseExceptionFormatter(logging.Formatter):
  def formatException(self, exc_info):
    msg = stackprinter.format(
      exc_info,
      ...
      suppressed_exceptions=[KeyboardInterrupt, SystemExit],
      ...
    )
    return "\n".join("  ┆ " + "%s"%(line) for line in msg.split("\n"))

cknd commented

Hey, thank you very much for the detailed report! Fixed in the latest release 0.2.11