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.
This commit is contained in:
Alexander Sosedkin 2018-08-22 02:12:08 +07:00
parent a74169b45b
commit 0a9899a7cf
2 changed files with 14 additions and 1 deletions

View file

@ -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

View file

@ -29,7 +29,7 @@ def _CHARACTER_MAP():
def _cache_renamer(path, code=False): def _cache_renamer(path, code=False):
if not code: 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 = [''.join(_CHARACTER_MAP.get(i, i) for i in w) for w in _splitpath(path)]
o[-1] = "{}.{}".format(o[-1], sys.implementation.cache_tag) o[-1] = "{}.{}".format(o[-1], sys.implementation.cache_tag)
return o return o