From bc7343c2061ee01e039b80b07ae39609726f962c Mon Sep 17 00:00:00 2001 From: Peter-Schorn Date: Wed, 14 Apr 2021 10:26:59 -0500 Subject: [PATCH] Fixed a bug in `CacheFileHandler.__init__`: The documentation says that the username will be retrieved from the environment, but it wasn't. --- CHANGELOG.md | 4 ++++ spotipy/cache_handler.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80eaecc..0d60d2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added `MemoryCacheHandler`, a cache handler that simply stores the token info in memory as an instance attribute of this class. +### Fixed + +* Fixed a bug in `CacheFileHandler.__init__`: The documentation says that the username will be retrieved from the environment, but it wasn't. + ## [2.18.0] - 2021-04-13 ### Added diff --git a/spotipy/cache_handler.py b/spotipy/cache_handler.py index ae3cae8..544316b 100644 --- a/spotipy/cache_handler.py +++ b/spotipy/cache_handler.py @@ -3,6 +3,8 @@ __all__ = ['CacheHandler', 'CacheFileHandler', 'MemoryCacheHandler'] import errno import json import logging +import os +from spotipy.util import CLIENT_CREDS_ENV_VARS logger = logging.getLogger(__name__) @@ -53,6 +55,7 @@ class CacheFileHandler(CacheHandler): self.cache_path = cache_path else: cache_path = ".cache" + username = (username or os.getenv(CLIENT_CREDS_ENV_VARS["client_username"])) if username: cache_path += "-" + str(username) self.cache_path = cache_path