diff options
author | Florian Bruhin <git@the-compiler.org> | 2016-07-25 13:03:58 +0200 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2016-07-25 13:03:58 +0200 |
commit | 15645636626a3635e906cb3f36d0c83204a154cf (patch) | |
tree | c1defac9b18b5fa0655b9203f4a9bfb621c8a652 | |
parent | c3f53312afb5f75e17ef6d20bd6b289f62d79187 (diff) | |
download | qutebrowser-15645636626a3635e906cb3f36d0c83204a154cf.tar.gz qutebrowser-15645636626a3635e906cb3f36d0c83204a154cf.zip |
Don't enable warnings if log was never inited
Otherwise, anything importing qtutils (which uses ignore_py_warnings
on module level) would enable warnings. This means pylint showed its own
warnings because of qute_pylint.config.
-rw-r--r-- | qutebrowser/utils/log.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index a1210caf0..18bec85f7 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -38,6 +38,8 @@ try: except ImportError: colorama = None +_log_inited = False + COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'purple', 'cyan', 'white'] COLOR_ESCAPES = {color: '\033[{}m'.format(i) for i, color in enumerate(COLORS, start=30)} @@ -169,6 +171,8 @@ def init_log(args): logging.captureWarnings(True) _init_py_warnings() QtCore.qInstallMessageHandler(qt_message_handler) + global _log_inited + _log_inited = True def _init_py_warnings(): @@ -189,10 +193,11 @@ def disable_qt_msghandler(): @contextlib.contextmanager def ignore_py_warnings(**kwargs): - """Contextmanager to temporarily hke certain Python warnings.""" + """Contextmanager to temporarily disable certain Python warnings.""" warnings.filterwarnings('ignore', **kwargs) yield - _init_py_warnings() + if _log_inited: + _init_py_warnings() def _init_handlers(level, color, force_color, json_logging, ram_capacity): |