Skip to content

paths.set_temp_cache and paths.set_temp_config don't reset value if exception occurs in creation #9704

@aarchiba

Description

@aarchiba

Description

The context managers paths.set_temp_cache and paths.set_temp_config are supposed to let users temporarily reset the locations of the astropy cache and config file. These are used in the test suite but are also user-visible. Unfortunately, as context managers, if an exception occurs in their __enter__ methods, their __exit__ methods are never called; these exit methods are what is supposed to reset the values to their original state, so if an exception is produced, say because something is badly wrong with the requested cache setup, the bogus cache setup is left behind.

This appears as bug #9634 and PR #9703 revealed and should fix the problem; there should be an example in the code for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions