Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
den-kar opened this issue Oct 5, 2023 · 2 comments

Comments

@den-kar
Copy link

den-kar commented Oct 5, 2023

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
Copy link
Owner

cknd commented Nov 24, 2023

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

@cknd cknd closed this as completed Nov 24, 2023
@cknd
Copy link
Owner

cknd commented Nov 24, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants