# HG changeset patch # User catherine@Drou # Date 1266382915 18000 # Node ID 5e3f918c41d8e95a9d2a1a666c0a390b5fa44a2d # Parent 798c7f32a96042048d05a7879cd0da34f0aa2f72 fixed bug in empty values diff -r 798c7f32a960 -r 5e3f918c41d8 cmd2.py --- 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 ( diff -r 798c7f32a960 -r 5e3f918c41d8 docs/pycon2010/pycon2010.rst --- 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