diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py index 08c933a6e..def252a91 100644 --- a/qutebrowser/misc/earlyinit.py +++ b/qutebrowser/misc/earlyinit.py @@ -299,9 +299,20 @@ def check_libraries(args): else: modules['PyQt5.QtWebKit'] = _missing_str("PyQt5.QtWebKit") + from qutebrowser.utils import log + for name, text in modules.items(): try: - importlib.import_module(name) + # https://github.com/pallets/jinja/pull/628 + # https://bitbucket.org/birkenfeld/pygments-main/issues/1314/ + # https://github.com/pallets/jinja/issues/646 + # https://bitbucket.org/fdik/pypeg/commits/dd15ca462b532019c0a3be1d39b8ee2f3fa32f4e + messages = ['invalid escape sequence', + 'Flags not at the start of the expression'] + with log.ignore_py_warnings( + category=DeprecationWarning, + message=r'({})'.format('|'.join(messages))): + importlib.import_module(name) except ImportError as e: _die(text, e) diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index d96eca9a3..07ec78741 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -200,22 +200,6 @@ def _init_py_warnings(): """Initialize Python warning handling.""" warnings.simplefilter('default') warnings.filterwarnings('ignore', module='pdb', category=ResourceWarning) - # https://github.com/pallets/jinja/pull/628 - warnings.filterwarnings('ignore', module=r'jinja2\.filters', - category=DeprecationWarning, - message='Flags not at the start of the expression') - # https://bitbucket.org/birkenfeld/pygments-main/issues/1314/ - warnings.filterwarnings('ignore', module=r'pygments\.util', - category=DeprecationWarning, - message='Flags not at the start of the expression') - # https://github.com/pallets/jinja/issues/646 - warnings.filterwarnings('ignore', module=r'jinja2\..*', - category=DeprecationWarning, - message='invalid escape sequence') - # https://bitbucket.org/fdik/pypeg/commits/dd15ca462b532019c0a3be1d39b8ee2f3fa32f4e - warnings.filterwarnings('ignore', module='pypeg2', - category=DeprecationWarning, - message='invalid escape sequence') @contextlib.contextmanager