File: syntaxerror_without_traceback.py

package info (click to toggle)
loguru 0.7.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,568 kB
  • sloc: python: 13,164; javascript: 49; makefile: 14
file content (20 lines) | stat: -rw-r--r-- 416 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sys

from loguru import logger


def test(diagnose, backtrace):
    logger.remove()
    logger.add(sys.stderr, format="", diagnose=diagnose, backtrace=backtrace, colorize=True)

    try:
        exec("foo =")
    except SyntaxError:
        type_, value, _ = sys.exc_info()
        logger.opt(exception=(type_, value, None)).error("")


test(False, False)
test(True, False)
test(False, True)
test(True, True)