From ec9735d7bfed53d680435ea80ea2bea127a15b66 2005-08-16 17:34:44 From: fperez Date: 2005-08-16 17:34:44 Subject: [PATCH] * IPython/iplib.py (runsource): remove self.code_to_run_src attribute. I realized this is nothing more than '\n'.join(self.buffer), and having the same data in two different places is just asking for synchronization bugs. This may impact people who have custom exception handlers, so I need to warn ipython-dev about it (F. Mantegazza may use them). * Fix http://www.scipy.net/roundup/ipython/issue38 --- diff --git a/IPython/Shell.py b/IPython/Shell.py index 0637c4c..35ec3eb 100644 --- a/IPython/Shell.py +++ b/IPython/Shell.py @@ -4,7 +4,7 @@ All the matplotlib support code was co-developed with John Hunter, matplotlib's author. -$Id: Shell.py 634 2005-07-17 01:56:45Z tzanko $""" +$Id: Shell.py 703 2005-08-16 17:34:44Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez @@ -312,7 +312,6 @@ class MTInteractiveShell(InteractiveShell): # Case 3 # Store code in self, so the execution thread can handle it self.thread_ready.acquire() - self.code_to_run_src = source self.code_to_run = code self.thread_ready.wait() # Wait until processed in timeout interval self.thread_ready.release() diff --git a/IPython/genutils.py b/IPython/genutils.py index 6227c09..efde7c3 100644 --- a/IPython/genutils.py +++ b/IPython/genutils.py @@ -5,7 +5,7 @@ General purpose utilities. This is a grab-bag of stuff I find useful in most programs I write. Some of these things are also convenient when working at the command line. -$Id: genutils.py 645 2005-07-19 01:59:26Z fperez $""" +$Id: genutils.py 703 2005-08-16 17:34:44Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez. @@ -14,6 +14,8 @@ $Id: genutils.py 645 2005-07-19 01:59:26Z fperez $""" # the file COPYING, distributed as part of this software. #***************************************************************************** +from __future__ import generators # 2.2 compatibility + from IPython import Release __author__ = '%s <%s>' % Release.authors['Fernando'] __license__ = Release.license @@ -23,7 +25,6 @@ __license__ = Release.license import __main__ import types,commands,time,sys,os,re,shutil import tempfile -import codecs from IPython.Itpl import Itpl,itpl,printpl from IPython import DPyGetOpt diff --git a/IPython/iplib.py b/IPython/iplib.py index 4591960..6d467ea 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.1 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 638 2005-07-18 03:01:41Z fperez $ +$Id: iplib.py 703 2005-08-16 17:34:44Z fperez $ """ #***************************************************************************** @@ -623,7 +623,6 @@ class InteractiveShell(code.InteractiveConsole, Logger, Magic): # other situations. No need to use a Queue here, since it's a single # item which gets cleared once run. self.code_to_run = None - self.code_to_run_src = '' # corresponding source # Job manager (for jobs run as background threads) self.jobs = BackgroundJobManager() @@ -867,7 +866,7 @@ class InteractiveShell(code.InteractiveConsole, Logger, Magic): print 'Exception type :',etype print 'Exception value:',value print 'Traceback :',tb - print 'Source code :',self.code_to_run_src + print 'Source code :','\n'.join(self.buffer) if handler is None: handler = dummy_handler @@ -1529,6 +1528,7 @@ want to merge them back into the new files.""" % locals() The return value can be used to decide whether to use sys.ps1 or sys.ps2 to prompt the next line.""" + try: code = self.compile(source, filename, symbol) except (OverflowError, SyntaxError, ValueError): @@ -1541,9 +1541,10 @@ want to merge them back into the new files.""" % locals() return True # Case 3 - # We store the code source and object so that threaded shells and + # We store the code object so that threaded shells and # custom exception handlers can access all this info if needed. - self.code_to_run_src = source + # The source corresponding to this can be obtained from the + # buffer attribute as '\n'.join(self.buffer). self.code_to_run = code # now actually execute the code object if self.runcode(code) == 0: @@ -1589,7 +1590,6 @@ want to merge them back into the new files.""" % locals() print # Flush out code object which has been run (and source) self.code_to_run = None - self.code_to_run_src = '' return outflag def raw_input(self, prompt=""): @@ -1767,6 +1767,7 @@ want to merge them back into the new files.""" % locals() pre=None,iFun=None,theRest=None): """Execute the line in a shell, empty return value""" + #print 'line in :', `line` # dbg # Example of a special handler. Others follow a similar pattern. if continue_prompt: # multi-line statements if iFun.startswith('!!'): @@ -1775,6 +1776,7 @@ want to merge them back into the new files.""" % locals() else: cmd = ("%s %s" % (iFun[1:],theRest)).replace('"','\\"') line_out = '%s%s.system("%s")' % (pre,self.name,cmd) + #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')' else: # single-line input if line.startswith('!!'): # rewrite iFun/theRest to properly hold the call to %sx and @@ -1787,9 +1789,12 @@ want to merge them back into the new files.""" % locals() else: cmd = esc_quotes(line[1:]) line_out = '%s.system("%s")' % (self.name,cmd) + #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')' # update cache/log and return self.log(line_out,continue_prompt) self.update_cache(line_out) # readline cache gets normal line + #print 'line out r:', `line_out` # dbg + #print 'line out s:', line_out # dbg return line_out def handle_magic(self, line, continue_prompt=None, diff --git a/IPython/ultraTB.py b/IPython/ultraTB.py index 4d4c2fe..44648a1 100644 --- a/IPython/ultraTB.py +++ b/IPython/ultraTB.py @@ -60,7 +60,7 @@ You can implement other color schemes easily, the syntax is fairly self-explanatory. Please send back new schemes you develop to the author for possible inclusion in future releases. -$Id: ultraTB.py 636 2005-07-17 03:11:11Z fperez $""" +$Id: ultraTB.py 703 2005-08-16 17:34:44Z fperez $""" #***************************************************************************** # Copyright (C) 2001 Nathaniel Gray @@ -639,7 +639,8 @@ class VerboseTB(TBTools): exception = ['%s%s%s: %s' % (Colors.excName, etype_str, ColorsNormal, evalue_str)] if type(evalue) is types.InstanceType: - for name in dir(evalue): + names = [w for w in dir(evalue) if isinstance(w, basestring)] + for name in names: value = text_repr(getattr(evalue, name)) exception.append('\n%s%s = %s' % (indent, name, value)) # return all our info assembled as a single string diff --git a/doc/ChangeLog b/doc/ChangeLog index b6a9237..c7777cd 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,26 @@ +2005-08-16 Fernando Perez + + * IPython/ultraTB.py (VerboseTB.text): don't crash if object + contains non-string attribute. Closes + http://www.scipy.net/roundup/ipython/issue38. + +2005-08-14 Fernando Perez + + * tools/ipsvnc: Minor improvements, to add changeset info. + +2005-08-12 Fernando Perez + + * IPython/iplib.py (runsource): remove self.code_to_run_src + attribute. I realized this is nothing more than + '\n'.join(self.buffer), and having the same data in two different + places is just asking for synchronization bugs. This may impact + people who have custom exception handlers, so I need to warn + ipython-dev about it (F. Mantegazza may use them). + +2005-07-29 Fernando Perez + + * IPython/genutils.py: fix 2.2 compatibility (generators) + 2005-07-18 Fernando Perez * IPython/genutils.py (get_home_dir): fix to help users with