From 0a9899a7cf9c5cca146c0d6fbeada46322024d50 Mon Sep 17 00:00:00 2001 From: Alexander Sosedkin Date: Wed, 22 Aug 2018 02:12:08 +0700 Subject: [PATCH] cache scripts by realpath Cache scripts by realpath, resolving symlinks, as per discussion in #2776. I chose realpath(...) over abspath(realpath(...)), as realpath does call abspath internally. --- news/cache-by-realpath.rst | 13 +++++++++++++ xonsh/codecache.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 news/cache-by-realpath.rst diff --git a/news/cache-by-realpath.rst b/news/cache-by-realpath.rst new file mode 100644 index 000000000..8a81b579c --- /dev/null +++ b/news/cache-by-realpath.rst @@ -0,0 +1,13 @@ +**Added:** None + +**Changed:** None + +**Deprecated:** None + +**Removed:** None + +**Fixed:** + +* Scripts are now cached by their realpath, not just abspath. + +**Security:** None diff --git a/xonsh/codecache.py b/xonsh/codecache.py index 96d72734c..31b7a1fcb 100644 --- a/xonsh/codecache.py +++ b/xonsh/codecache.py @@ -29,7 +29,7 @@ def _CHARACTER_MAP(): def _cache_renamer(path, code=False): if not code: - path = os.path.abspath(path) + path = os.path.realpath(path) o = [''.join(_CHARACTER_MAP.get(i, i) for i in w) for w in _splitpath(path)] o[-1] = "{}.{}".format(o[-1], sys.implementation.cache_tag) return o