From 1115cbd94dcae6fb7b215c51f0407333c92c956e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20M=C3=A4usezahl?= Date: Sun, 10 May 2020 11:16:12 +0200 Subject: [PATCH] This fixes two issues with the caching on Windows: * the cache directory should really be %LOCALAPPDATA% * ~ is not a meaningful directory on Windows. It should really be os.path.expanduser('~'). To be honest it is probably always safe to assume that os.getenv('LOCALAPPDATA') executes to something sensible on any Windows system that hasn't been tampered with. --- AUTHORS.txt | 1 + jedi/settings.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index d04cc48c..f28e1c90 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -57,6 +57,7 @@ Code Contributors - Tim Gates (@timgates42) - Lior Goldberg (@goldberglior) - Ryan Clary (@mrclary) +- Max Mäusezahl (@mmaeusezahl) And a few more "anonymous" contributors. diff --git a/jedi/settings.py b/jedi/settings.py index 1573d59c..6764a3e5 100644 --- a/jedi/settings.py +++ b/jedi/settings.py @@ -69,8 +69,8 @@ Adds an opening bracket after a function for completions. # ---------------- if platform.system().lower() == 'windows': - _cache_directory = os.path.join(os.getenv('APPDATA') or '~', 'Jedi', - 'Jedi') + _cache_directory = os.path.join(os.getenv('LOCALAPPDATA') or + os.path.expanduser('~'), 'Jedi', 'Jedi') elif platform.system().lower() == 'darwin': _cache_directory = os.path.join('~', 'Library', 'Caches', 'Jedi') else: @@ -81,7 +81,7 @@ cache_directory = os.path.expanduser(_cache_directory) The path where the cache is stored. On Linux, this defaults to ``~/.cache/jedi/``, on OS X to -``~/Library/Caches/Jedi/`` and on Windows to ``%APPDATA%\\Jedi\\Jedi\\``. +``~/Library/Caches/Jedi/`` and on Windows to ``%LOCALAPPDATA%\\Jedi\\Jedi\\``. On Linux, if the environment variable ``$XDG_CACHE_HOME`` is set, ``$XDG_CACHE_HOME/jedi`` is used instead of the default one. """