Author: bugman Date: Fri Dec 17 16:43:21 2010 New Revision: 11873 URL: http://svn.gna.org/viewcvs/relax?rev=11873&view=rev Log: Fix for script execution - the original state is restored if an exception occurs. The original working directory is restored and the script path is removed in all cases by using a try-finally setup. Modified: 1.3/prompt/interpreter.py Modified: 1.3/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/interpreter.py?rev=11873&r1=11872&r2=11873&view=diff ============================================================================== --- 1.3/prompt/interpreter.py (original) +++ 1.3/prompt/interpreter.py Fri Dec 17 16:43:21 2010 @@ -366,14 +366,15 @@ raise RelaxError("The relax script must not contain the '.' character (except before the extension '*.py').") # Execute the module. - runpy.run_module(module, globals) - - # Switch back to the original working directory. - if head: - chdir(orig_dir) - - # Remove the script path. - sys.path.pop(sys.path.index(script_path)) + try: + runpy.run_module(module, globals) + finally: + # Switch back to the original working directory. + if head: + chdir(orig_dir) + + # Remove the script path. + sys.path.pop(sys.path.index(script_path)) # Unlock execution if needed. status.exec_lock.release()