Author: bugman Date: Fri Dec 17 16:48:24 2010 New Revision: 11878 URL: http://svn.gna.org/viewcvs/relax?rev=11878&view=rev Log: Merged revisions 11873 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r11873 | bugman | 2010-12-17 16:43:21 +0100 (Fri, 17 Dec 2010) | 6 lines 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: branches/relax_disp/ (props changed) branches/relax_disp/prompt/interpreter.py Propchange: branches/relax_disp/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri Dec 17 16:48:24 2010 @@ -1,1 +1,1 @@ -/1.3:1-11870 +/1.3:1-11877 Modified: branches/relax_disp/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/prompt/interpreter.py?rev=11878&r1=11877&r2=11878&view=diff ============================================================================== --- branches/relax_disp/prompt/interpreter.py (original) +++ branches/relax_disp/prompt/interpreter.py Fri Dec 17 16:48:24 2010 @@ -368,14 +368,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()