Explicit global _keyring_backend and better dynamic import
Since they matched a closely related functionality in the very same file, those two features were actually merged into a single one.
1) the way _keyring_backend was used in core.py relied on the way the _keyring_backend name was set during import. This could work but could lead to very strange issues sometimes.
The patch provides an explicit global keyword which allows performing the very same task in a cleaner way. NOTE: _keyring_backend was actually meant to be a global even before this patch, but it was used inconsistenly. Looking at all the functions employing _keyring_backend, they will simply crash with a NameError if _keyring_backend is unset, but how is it set is unclear.
A better approach would be use a registry and not to rely on global, I'll try that in a further patch.
2) Don't reinvent the wheel and use a tested function to dynamically import Keyring backend classes. This patch employs a function from the Twisted project with small modifications.