Return line composing the exception message.
(typ, exc, tb)
| 229 | |
| 230 | |
| 231 | def get_message_lines(typ, exc, tb): |
| 232 | "Return line composing the exception message." |
| 233 | if typ in (AttributeError, NameError): |
| 234 | # 3.10+ hints are not directly accessible from python (#44026). |
| 235 | err = io.StringIO() |
| 236 | with contextlib.redirect_stderr(err): |
| 237 | sys.__excepthook__(typ, exc, tb) |
| 238 | return [err.getvalue().split("\n")[-2] + "\n"] |
| 239 | else: |
| 240 | return traceback.format_exception_only(typ, exc) |
| 241 | |
| 242 | |
| 243 | def print_exception(): |
no test coverage detected
searching dependent graphs…