From cf1fa88fb2b7b2e221f3b9920fdba3ee591cf590 2007-04-26 14:41:43 From: jdh2358 Date: 2007-04-26 14:41:43 Subject: [PATCH] - Fix state handling bug in format(). Closes #146. --- diff --git a/IPython/PyColorize.py b/IPython/PyColorize.py index 05d155c..55e3ed9 100755 --- a/IPython/PyColorize.py +++ b/IPython/PyColorize.py @@ -28,7 +28,7 @@ scan Python source code and re-emit it with no changes to its original formatting (which is the hard part). - $Id: PyColorize.py 2225 2007-04-08 02:48:16Z jdh2358 $""" + $Id: PyColorize.py 2274 2007-04-26 14:41:43Z jdh2358 $""" __all__ = ['ANSICodeColors','Parser'] @@ -133,7 +133,12 @@ class Parser: string.""" string_output = 0 - if out == 'str' or self.out == 'str': + if out == 'str' or self.out == 'str' or \ + isinstance(self.out,cStringIO.OutputType): + # XXX - I don't really like this state handling logic, but at this + # point I don't want to make major changes, so adding the + # isinstance() check is the simplest I can do to ensure correct + # behavior. out_old = self.out self.out = cStringIO.StringIO() string_output = 1 diff --git a/doc/ChangeLog b/doc/ChangeLog index 6275c2f..a481ed9 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2007-04-26 Fernando Perez + + * IPython/PyColorize.py (Parser.format2): fix state-handling + logic. I still don't like how that code handles state, but at + least now it should be correct, if inelegant. Closes #146. + 2007-04-25 Ville Vainio * Extensions/ipy_which.py: added extension for %which magic, works