From 228b3b54172481d917cd25294bb87dd22bec32ec 2010-01-30 22:36:40 From: Brian Granger Date: 2010-01-30 22:36:40 Subject: [PATCH] Fixed bug in ultratb.py and io.py. Previously :class:`IPython.utils.io.Term` had a :meth:`Term.writeln` method that :mod:`ultratb.py` was using. But, when a real stream or files is used in :class:`IPython.utils.io.Term` it doesn't have this method, so we were getting an error when the IPython Sphinx directive was run. I removed this method and made :mod:`ultratb.py` use just ``write``. --- diff --git a/IPython/core/ultratb.py b/IPython/core/ultratb.py index 404559f..d5b3e22 100644 --- a/IPython/core/ultratb.py +++ b/IPython/core/ultratb.py @@ -385,7 +385,8 @@ class ListTB(TBTools): def __call__(self, etype, value, elist): Term.cout.flush() - Term.cerr.writeln(self.text(etype,value,elist)) + Term.cerr.write(self.text(etype,value,elist)) + Term.cerr.write('\n') def text(self, etype, value, elist, context=5): """Return a color formatted string with the traceback info. @@ -910,7 +911,8 @@ class VerboseTB(TBTools): (etype, evalue, etb) = info or sys.exc_info() self.tb = etb Term.cout.flush() - Term.cerr.writeln(self.text(etype, evalue, etb)) + Term.cerr.write(self.text(etype, evalue, etb)) + Term.cerr.write('\n') # Changed so an instance can just be called as VerboseTB_inst() and print # out the right info on its own. diff --git a/IPython/utils/io.py b/IPython/utils/io.py index c9bdd5f..30408e2 100644 --- a/IPython/utils/io.py +++ b/IPython/utils/io.py @@ -47,10 +47,10 @@ class IOStream: print >> sys.stderr, \ 'ERROR - failed to write data to stream:', self.stream - def writeln(self, data): - self.write(data) - self.write('\n') - + # This class used to have a writeln method, but regular files and streams + # in Python don't have this method. We need to keep this completely + # compatible so we removed it. + def close(self): pass