From 8a269867c03589c14c08f0f6270e20c0b4c9625d Mon Sep 17 00:00:00 2001 From: Tor Arvid Lund Date: Thu, 26 Sep 2024 10:29:23 +0200 Subject: [PATCH 1/2] Expand user home directory in config When reading the keyring_path from the config file, this would previously fail: keyring_path=~/foo/bar (it would need to be /home/peterpan/foo/bar or similar instead) This commit fixes this issue by wrapping the path in os.path.expanduser --- keyring/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyring/core.py b/keyring/core.py index ef18128e..bbdb3e47 100644 --- a/keyring/core.py +++ b/keyring/core.py @@ -195,6 +195,6 @@ def _load_keyring_path(config: configparser.RawConfigParser) -> None: "load the keyring-path option (if present)" try: path = config.get("backend", "keyring-path").strip() - sys.path.insert(0, path) + sys.path.insert(0, os.path.expanduser(path)) except (configparser.NoOptionError, configparser.NoSectionError): pass From 4504133ddebc80323e55499007ca1eb3c2311fbb Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 26 Oct 2024 09:48:34 -0400 Subject: [PATCH 2/2] Add news fragment. --- newsfragments/696.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/696.feature.rst diff --git a/newsfragments/696.feature.rst b/newsfragments/696.feature.rst new file mode 100644 index 00000000..7dd16761 --- /dev/null +++ b/newsfragments/696.feature.rst @@ -0,0 +1 @@ +When parsing ``keyring_path`` from the config, the home directory is now expanded from ``~``. \ No newline at end of file