diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index 48f8759c1..2bdb5d263 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -198,7 +198,7 @@ def read_config_py(filename=None): try: code = compile(source, filename, 'exec') - except ValueError as e: + except (ValueError, TypeError) as e: # source contains NUL bytes desc = configexc.ConfigErrorDesc("Error while compiling", e) raise configexc.ConfigFileErrors(basename, [desc]) diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py index d739b6b7c..c10b0c4b4 100644 --- a/tests/unit/config/test_configfiles.py +++ b/tests/unit/config/test_configfiles.py @@ -236,7 +236,7 @@ class TestConfigPy: assert len(excinfo.value.errors) == 1 error = excinfo.value.errors[0] - assert isinstance(error.exception, ValueError) + assert isinstance(error.exception, (TypeError, ValueError)) assert error.text == "Error while compiling" exception_text = 'source code string cannot contain null bytes' assert str(error.exception) == exception_text