cknd / stackprinter

Debugging-friendly exceptions for Python
MIT License
1.28k stars 37 forks source link

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

Closed den-kar closed 11 months ago

den-kar commented 1 year ago

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 11 months ago

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

cknd commented 11 months ago

link to release notes https://github.com/cknd/stackprinter/releases/tag/0.2.11