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.
Description
The context managers
paths.set_temp_cacheandpaths.set_temp_configare 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.