Hi Collin, > ... It seems like a pain to track > down every code path that can lead to 'sys.exit()' or 'exit()' with a > temporary directory still existing. > ... > Therefore, we can use tempfile.TemporaryDirectory as a context manager > and let Python cleanup for us [1]: > > def main_with_exception_handling() -> None: > try: # Try to execute > - main() > + with tempfile.TemporaryDirectory() as temporary_directory: > + main(temporary_directory) > except GLError as error: > errmode = 0 # gnulib-style errors > errno = error.errno
Yes, that's a nice improvement. I agree, the 'with' statement with automatic resource cleanup is exactly the right tool for this situation. Bruno