diff --git a/keyring/core.py b/keyring/core.py index bbdb3e47..da47e02e 100644 --- a/keyring/core.py +++ b/keyring/core.py @@ -178,7 +178,7 @@ def load_config() -> typing.Optional[backend.KeyringBackend]: if config.has_section("backend"): keyring_name = config.get("backend", "default-keyring").strip() else: - raise configparser.NoOptionError('backend', 'default-keyring') + return None except (configparser.NoOptionError, ImportError): logger = logging.getLogger('keyring') diff --git a/tests/test_core.py b/tests/test_core.py index 083bcfd5..eb29a4b0 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -25,6 +25,12 @@ def test_load_config_missing(caplog, config_path): assert not caplog.records +def test_load_empty_config(caplog, config_path): + config_path.write_text("", encoding='utf-8') + assert keyring.core.load_config() is None + assert not caplog.records + + fail_config = textwrap.dedent( """ [backend]