Skip to content

lazy_import_cache.get_cache_file doesn't work well if DOT_SAGE doesn't end with a slash #11924

@jhpalmieri

Description

@jhpalmieri

The function get_cache_file in sage/misc/lazy_import_cache.py uses this code:

return "%s%s-lazy_import_cache.pickle" % (
       os.environ['DOT_SAGE'], 
       os.path.realpath(os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage')).replace(os.sep, '_'))

Since this just appends to DOT_SAGE, it returns a file in a different directory depending on whether DOT_SAGE ends with a slash or not: if DOT_SAGE is /home/user/.sage/, then this gives

/home/user/.sage/_mangled_SAGE_ROOT_...

whereas if DOT_SAGE is /home/user/.sage, then it gives

/home/user/.sage_mangled_SAGE_ROOT_...

which is a file in the directory /home/user/, not in .sage/.

The attached patch uses os.path.join to combine the parts of the path correctly. (I also wonder if it would be a good idea to store the cache file in a different directory, say DOT_SAGE/cache/, so it's hidden more than it is currently?)

Component: misc

Author: John Palmieri

Reviewer: Jeroen Demeyer

Merged: sage-4.8.alpha3

Issue created by migration from https://trac.sagemath.org/ticket/11924

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions