changeset 353:5e3f918c41d8

fixed bug in empty values
author catherine@Drou
date Wed, 17 Feb 2010 00:01:55 -0500
parents 798c7f32a960
children 7cd04727f7f7
files cmd2.py docs/pycon2010/pycon2010.rst
diffstat 2 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Tue Feb 16 23:08:17 2010 -0500
+++ b/cmd2.py	Wed Feb 17 00:01:55 2010 -0500
@@ -749,26 +749,27 @@
     def onecmd_plus_hooks(self, line):
         stop = 0
         try:
-            try:
-                statement = self.complete_statement(line)
-            except EmptyStatement:
-                return 0            
+            statement = self.complete_statement(line)
             (stop, statement) = self.postparsing_precmd(statement)
             if stop:
                 return self.postparsing_postcmd(stop)
             if statement.parsed.command not in self.excludeFromHistory:
-                self.history.append(statement.parsed.raw)        
-            self.redirect_output(statement)
-            timestart = datetime.datetime.now()
-            statement = self.precmd(statement)
-            stop = self.onecmd(statement)
-            stop = self.postcmd(stop, statement)
-            if self.timing:
-                self.pfeedback('Elapsed: %s' % str(datetime.datetime.now() - timestart))
+                self.history.append(statement.parsed.raw)      
+            try:
+                self.redirect_output(statement)
+                timestart = datetime.datetime.now()
+                statement = self.precmd(statement)
+                stop = self.onecmd(statement)
+                stop = self.postcmd(stop, statement)
+                if self.timing:
+                    self.pfeedback('Elapsed: %s' % str(datetime.datetime.now() - timestart))
+            finally:
+                self.restore_output(statement)
+        except EmptyStatement:
+            return 0
         except Exception, e:
             self.perror(str(e), statement)            
         finally:
-            self.restore_output(statement)
             return self.postparsing_postcmd(stop)        
     def complete_statement(self, line):
         if (not line) or (
--- a/docs/pycon2010/pycon2010.rst	Tue Feb 16 23:08:17 2010 -0500
+++ b/docs/pycon2010/pycon2010.rst	Wed Feb 17 00:01:55 2010 -0500
@@ -277,5 +277,4 @@
             separator = ' '
         chant = separator.join(chant)
         print('{0} and a bottle of {1}'.format(chant, arg))
-
         
\ No newline at end of file