diff --git a/IPython/ColorANSI.py b/IPython/ColorANSI.py index 420f706..b8504b7 100644 --- a/IPython/ColorANSI.py +++ b/IPython/ColorANSI.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Tools for coloring text in ANSI terminals. -$Id: ColorANSI.py 410 2004-11-04 07:58:17Z fperez $""" +$Id: ColorANSI.py 951 2005-12-25 00:57:24Z fperez $""" #***************************************************************************** # Copyright (C) 2002-2004 Fernando Perez. @@ -17,7 +17,6 @@ __license__ = Release.license __all__ = ['TermColors','InputTermColors','ColorScheme','ColorSchemeTable'] import os -from UserDict import UserDict from IPython.Struct import Struct @@ -94,8 +93,14 @@ class ColorScheme: self.colors = Struct(**colormap) else: self.colors = Struct(colordict) + + def copy(self,name=None): + """Return a full copy of the object, optionally renaming it.""" + if name is None: + name = self.name + return ColorScheme(name,self.colors.__dict__) -class ColorSchemeTable(UserDict): +class ColorSchemeTable(dict): """General class to handle tables of color schemes. It's basically a dict of color schemes with a couple of shorthand @@ -112,17 +117,21 @@ class ColorSchemeTable(UserDict): the default active scheme. """ - UserDict.__init__(self) - if scheme_list is None: - self.active_scheme_name = '' - self.active_colors = None - else: + # create object attributes to be set later + self.active_scheme_name = '' + self.active_colors = None + + if scheme_list: if default_scheme == '': raise ValueError,'you must specify the default color scheme' for scheme in scheme_list: self.add_scheme(scheme) self.set_active_scheme(default_scheme) + def copy(self): + """Return full copy of object""" + return ColorSchemeTable(self.values(),self.active_scheme_name) + def add_scheme(self,new_scheme): """Add a new color scheme to the table.""" if not isinstance(new_scheme,ColorScheme): @@ -135,20 +144,20 @@ class ColorSchemeTable(UserDict): Names are by default compared in a case-insensitive way, but this can be changed by setting the parameter case_sensitive to true.""" - scheme_list = self.keys() + scheme_names = self.keys() if case_sensitive: - valid_schemes = scheme_list + valid_schemes = scheme_names scheme_test = scheme else: - valid_schemes = [s.lower() for s in scheme_list] + valid_schemes = [s.lower() for s in scheme_names] scheme_test = scheme.lower() try: scheme_idx = valid_schemes.index(scheme_test) except ValueError: raise ValueError,'Unrecognized color scheme: ' + scheme + \ - '\nValid schemes: '+str(scheme_list).replace("'', ",'') + '\nValid schemes: '+str(scheme_names).replace("'', ",'') else: - active = scheme_list[scheme_idx] + active = scheme_names[scheme_idx] self.active_scheme_name = active self.active_colors = self[active].colors # Now allow using '' as an index for the current active scheme diff --git a/IPython/CrashHandler.py b/IPython/CrashHandler.py index db535b5..056a296 100644 --- a/IPython/CrashHandler.py +++ b/IPython/CrashHandler.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """sys.excepthook for IPython itself, leaves a detailed report on disk. -$Id: CrashHandler.py 775 2005-09-01 20:24:59Z fperez $""" +$Id: CrashHandler.py 951 2005-12-25 00:57:24Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez. @@ -23,10 +23,10 @@ import os,sys from pprint import pprint,pformat # Homebrewed -from IPython.genutils import * from IPython.Itpl import Itpl,itpl,printpl +from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names from IPython import ultraTB -from IPython.ultraTB import ColorScheme,ColorSchemeTable # too long names +from IPython.genutils import * #**************************************************************************** class CrashHandler: diff --git a/IPython/Debugger.py b/IPython/Debugger.py index 5a030bc..6ab35b2 100644 --- a/IPython/Debugger.py +++ b/IPython/Debugger.py @@ -15,39 +15,250 @@ details on the PSF (Python Software Foundation) standard license, see: http://www.python.org/2.2.3/license.html -$Id: Debugger.py 590 2005-05-30 06:26:51Z fperez $""" +$Id: Debugger.py 951 2005-12-25 00:57:24Z fperez $""" from IPython import Release __author__ = '%s <%s>' % Release.authors['Fernando'] __license__ = 'Python' -import pdb,bdb,cmd,os,sys +import pdb,bdb,cmd,os,sys,linecache +from IPython import PyColorize, ColorANSI +from IPython.genutils import Term +from IPython.excolors import ExceptionColors + +def _file_lines(fname): + """Return the contents of a named file as a list of lines. + + This function never raises an IOError exception: if the file can't be + read, it simply returns an empty list.""" + + try: + outfile = open(fname) + except IOError: + return [] + else: + out = outfile.readlines() + outfile.close() + return out + class Pdb(pdb.Pdb): """Modified Pdb class, does not load readline.""" - def __init__(self): + def __init__(self,color_scheme='NoColor'): bdb.Bdb.__init__(self) cmd.Cmd.__init__(self,completekey=None) # don't load readline - self.prompt = '(Pdb) ' + self.prompt = 'ipdb> ' # The default prompt is '(Pdb)' self.aliases = {} # Read $HOME/.pdbrc and ./.pdbrc - self.rcLines = [] - if os.environ.has_key('HOME'): - envHome = os.environ['HOME'] - try: - rcFile = open(os.path.join(envHome, ".pdbrc")) - except IOError: - pass - else: - for line in rcFile.readlines(): - self.rcLines.append(line) - rcFile.close() try: - rcFile = open(".pdbrc") - except IOError: + self.rcLines = _file_lines(os.path.join(os.environ['HOME'], + ".pdbrc")) + except KeyError: + self.rcLines = [] + self.rcLines.extend(_file_lines(".pdbrc")) + + # Create color table: we copy the default one from the traceback + # module and add a few attributes needed for debugging + self.color_scheme_table = ExceptionColors.copy() + + # shorthands + C = ColorANSI.TermColors + cst = self.color_scheme_table + + cst['NoColor'].colors.breakpoint_enabled = C.NoColor + cst['NoColor'].colors.breakpoint_disabled = C.NoColor + + cst['Linux'].colors.breakpoint_enabled = C.LightRed + cst['Linux'].colors.breakpoint_disabled = C.Red + + cst['LightBG'].colors.breakpoint_enabled = C.LightRed + cst['LightBG'].colors.breakpoint_disabled = C.Red + + self.set_colors(color_scheme) + + def set_colors(self, scheme): + """Shorthand access to the color table scheme selector method.""" + self.color_scheme_table.set_active_scheme(scheme) + + + def interaction(self, frame, traceback): + __IPYTHON__.set_completer_frame(frame) + pdb.Pdb.interaction(self, frame, traceback) + + + def do_up(self, arg): + pdb.Pdb.do_up(self, arg) + __IPYTHON__.set_completer_frame(self.curframe) + do_u = do_up + + + def do_down(self, arg): + pdb.Pdb.do_down(self, arg) + __IPYTHON__.set_completer_frame(self.curframe) + do_d = do_down + + + def postloop(self): + __IPYTHON__.set_completer_frame(None) + + + def print_stack_trace(self): + try: + for frame_lineno in self.stack: + self.print_stack_entry(frame_lineno, context = 5) + except KeyboardInterrupt: pass + + + def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ', + context = 3): + frame, lineno = frame_lineno + print >>Term.cout, self.format_stack_entry(frame_lineno, '', context) + + + def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3): + import linecache, repr + + ret = "" + + Colors = self.color_scheme_table.active_colors + ColorsNormal = Colors.Normal + tpl_link = '%s%%s%s' % (Colors.filenameEm, ColorsNormal) + tpl_call = 'in %s%%s%s%%s%s' % (Colors.vName, Colors.valEm, ColorsNormal) + tpl_line = '%%s%s%%s %s%%s' % (Colors.lineno, ColorsNormal) + tpl_line_em = '%%s%s%%s %s%%s%s' % (Colors.linenoEm, Colors.line, + ColorsNormal) + + frame, lineno = frame_lineno + + return_value = '' + if '__return__' in frame.f_locals: + rv = frame.f_locals['__return__'] + #return_value += '->' + return_value += repr.repr(rv) + '\n' + ret += return_value + + #s = filename + '(' + `lineno` + ')' + filename = self.canonic(frame.f_code.co_filename) + link = tpl_link % filename + + if frame.f_code.co_name: + func = frame.f_code.co_name + else: + func = "" + + call = '' + if func != '?': + if '__args__' in frame.f_locals: + args = repr.repr(frame.f_locals['__args__']) + else: + args = '()' + call = tpl_call % (func, args) + + level = '%s %s\n' % (link, call) + ret += level + + start = lineno - 1 - context//2 + lines = linecache.getlines(filename) + start = max(start, 0) + start = min(start, len(lines) - context) + lines = lines[start : start + context] + + for i in range(len(lines)): + line = lines[i] + if start + 1 + i == lineno: + ret += self.__format_line(tpl_line_em, filename, start + 1 + i, line, arrow = True) + else: + ret += self.__format_line(tpl_line, filename, start + 1 + i, line, arrow = False) + + return ret + + + def __format_line(self, tpl_line, filename, lineno, line, arrow = False): + bp_mark = "" + bp_mark_color = "" + + bp = None + if lineno in self.get_file_breaks(filename): + bps = self.get_breaks(filename, lineno) + bp = bps[-1] + + if bp: + Colors = self.color_scheme_table.active_colors + bp_mark = str(bp.number) + bp_mark_color = Colors.breakpoint_enabled + if not bp.enabled: + bp_mark_color = Colors.breakpoint_disabled + + numbers_width = 7 + if arrow: + # This is the line with the error + pad = numbers_width - len(str(lineno)) - len(bp_mark) + if pad >= 3: + marker = '-'*(pad-3) + '-> ' + elif pad == 2: + marker = '> ' + elif pad == 1: + marker = '>' + else: + marker = '' + num = '%s%s' % (marker, str(lineno)) + line = tpl_line % (bp_mark_color + bp_mark, num, line) + else: + num = '%*s' % (numbers_width - len(bp_mark), str(lineno)) + line = tpl_line % (bp_mark_color + bp_mark, num, line) + + return line + + + def do_list(self, arg): + self.lastcmd = 'list' + last = None + if arg: + try: + x = eval(arg, {}, {}) + if type(x) == type(()): + first, last = x + first = int(first) + last = int(last) + if last < first: + # Assume it's a count + last = first + last + else: + first = max(1, int(x) - 5) + except: + print '*** Error in argument:', `arg` + return + elif self.lineno is None: + first = max(1, self.curframe.f_lineno - 5) else: - for line in rcFile.readlines(): - self.rcLines.append(line) - rcFile.close() + first = self.lineno + 1 + if last is None: + last = first + 10 + filename = self.curframe.f_code.co_filename + try: + Colors = self.color_scheme_table.active_colors + ColorsNormal = Colors.Normal + tpl_line = '%%s%s%%s %s%%s' % (Colors.lineno, ColorsNormal) + tpl_line_em = '%%s%s%%s %s%%s%s' % (Colors.linenoEm, Colors.line, ColorsNormal) + src = [] + for lineno in range(first, last+1): + line = linecache.getline(filename, lineno) + if not line: + break + + if lineno == self.curframe.f_lineno: + line = self.__format_line(tpl_line_em, filename, lineno, line, arrow = True) + else: + line = self.__format_line(tpl_line, filename, lineno, line, arrow = False) + + src.append(line) + self.lineno = lineno + + print >>Term.cout, ''.join(src) + + except KeyboardInterrupt: + pass + + do_l = do_list diff --git a/IPython/Magic.py b/IPython/Magic.py index e53207d..1fb7eba 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 923 2005-11-15 08:51:15Z fperez $""" +$Id: Magic.py 951 2005-12-25 00:57:24Z fperez $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -22,13 +22,16 @@ __license__ = Release.license # Python standard modules import __builtin__ import os,sys,inspect,pydoc,re,tempfile,pdb,bdb,time +import Debugger +from getopt import getopt +from pprint import pprint, pformat +from cStringIO import StringIO + +# profile isn't bundled by default in Debian for license reasons try: import profile,pstats except ImportError: profile = pstats = None -from getopt import getopt -from pprint import pprint, pformat -from cStringIO import StringIO # Homebrewed from IPython.Struct import Struct @@ -1371,7 +1374,7 @@ Currently the magic system has the following functions:\n""" stats = self.magic_prun('',0,opts,arg_lst,prog_ns) else: if opts.has_key('d'): - deb = pdb.Pdb() + deb = Debugger.Pdb(self.shell.rc.colors) # reset Breakpoint state, which is moronically kept # in a class bdb.Breakpoint.next = 1 @@ -1397,8 +1400,15 @@ Currently the magic system has the following functions:\n""" deb.do_break('%s:%s' % (filename,bp)) # Start file run print "NOTE: Enter 'c' at the", - print "(Pdb) prompt to start your script." - deb.run('execfile("%s")' % filename,prog_ns) + print "ipdb> prompt to start your script." + try: + deb.run('execfile("%s")' % filename,prog_ns) + except: + etype, value, tb = sys.exc_info() + # Skip three frames in the traceback: the %run one, + # one inside bdb.py, and the command-line typed by the + # user (run by exec in pdb itself). + self.shell.InteractiveTB(etype,value,tb,tb_offset=3) else: if runner is None: runner = self.shell.safe_execfile diff --git a/IPython/Prompts.py b/IPython/Prompts.py index b66441c..e872ca6 100644 --- a/IPython/Prompts.py +++ b/IPython/Prompts.py @@ -2,7 +2,7 @@ """ Classes for handling input/output prompts. -$Id: Prompts.py 638 2005-07-18 03:01:41Z fperez $""" +$Id: Prompts.py 951 2005-12-25 00:57:24Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez @@ -49,6 +49,7 @@ PromptColors.add_scheme(ColorANSI.ColorScheme( normal = Colors.NoColor # color off (usu. Colors.Normal) )) + # make some schemes as instances so we can copy them for modification easily: __PColLinux = ColorANSI.ColorScheme( 'Linux', @@ -64,8 +65,9 @@ __PColLinux = ColorANSI.ColorScheme( ) # Don't forget to enter it into the table! PromptColors.add_scheme(__PColLinux) + # Slightly modified Linux for light backgrounds -__PColLightBG = ColorANSI.ColorScheme('LightBG',**__PColLinux.colors.dict().copy()) +__PColLightBG = __PColLinux.copy('LightBG') __PColLightBG.colors.update( in_prompt = InputColors.Blue, diff --git a/IPython/Release.py b/IPython/Release.py index 72d2ad5..55d5ff2 100644 --- a/IPython/Release.py +++ b/IPython/Release.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Release data for the IPython project. -$Id: Release.py 775 2005-09-01 20:24:59Z fperez $""" +$Id: Release.py 951 2005-12-25 00:57:24Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2005 Fernando Perez @@ -24,7 +24,7 @@ name = 'ipython' version = '0.6.16.svn' -revision = '$Revision: 775 $' +revision = '$Revision: 951 $' description = "An enhanced interactive Python shell." @@ -69,6 +69,8 @@ authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'), url = 'http://ipython.scipy.org' +download_url = 'http://ipython.scipy.org/dist' + platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME'] keywords = ['Interactive','Interpreter','Shell'] diff --git a/IPython/excolors.py b/IPython/excolors.py new file mode 100644 index 0000000..785fc70 --- /dev/null +++ b/IPython/excolors.py @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- +""" +Color schemes for exception handling code in IPython. + +$Id: Prompts.py 638 2005-07-18 03:01:41Z fperez $""" + +#***************************************************************************** +# Copyright (C) 2005 Fernando Perez +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#***************************************************************************** + +from IPython import Release +__author__ = '%s <%s>' % Release.authors['Fernando'] +__license__ = Release.license +__version__ = Release.version + +#**************************************************************************** +# Required modules +from IPython.ColorANSI import ColorSchemeTable, TermColors, ColorScheme + +ExceptionColors = ColorSchemeTable() + +# Populate it with color schemes +C = TermColors # shorthand and local lookup +ExceptionColors.add_scheme(ColorScheme( + 'NoColor', + # The color to be used for the top line + topline = C.NoColor, + + # The colors to be used in the traceback + filename = C.NoColor, + lineno = C.NoColor, + name = C.NoColor, + vName = C.NoColor, + val = C.NoColor, + em = C.NoColor, + + # Emphasized colors for the last frame of the traceback + normalEm = C.NoColor, + filenameEm = C.NoColor, + linenoEm = C.NoColor, + nameEm = C.NoColor, + valEm = C.NoColor, + + # Colors for printing the exception + excName = C.NoColor, + line = C.NoColor, + caret = C.NoColor, + Normal = C.NoColor + )) + +# make some schemes as instances so we can copy them for modification easily +ExceptionColors.add_scheme(ColorScheme( + 'Linux', + # The color to be used for the top line + topline = C.LightRed, + + # The colors to be used in the traceback + filename = C.Green, + lineno = C.Green, + name = C.Purple, + vName = C.Cyan, + val = C.Green, + em = C.LightCyan, + + # Emphasized colors for the last frame of the traceback + normalEm = C.LightCyan, + filenameEm = C.LightGreen, + linenoEm = C.LightGreen, + nameEm = C.LightPurple, + valEm = C.LightBlue, + + # Colors for printing the exception + excName = C.LightRed, + line = C.Yellow, + caret = C.White, + Normal = C.Normal + )) + +# For light backgrounds, swap dark/light colors +ExceptionColors.add_scheme(ColorScheme( + 'LightBG', + # The color to be used for the top line + topline = C.Red, + + # The colors to be used in the traceback + filename = C.LightGreen, + lineno = C.LightGreen, + name = C.LightPurple, + vName = C.Cyan, + val = C.LightGreen, + em = C.Cyan, + + # Emphasized colors for the last frame of the traceback + normalEm = C.Cyan, + filenameEm = C.Green, + linenoEm = C.Green, + nameEm = C.Purple, + valEm = C.Blue, + + # Colors for printing the exception + excName = C.Red, + #line = C.Brown, # brown often is displayed as yellow + line = C.Red, + caret = C.Normal, + Normal = C.Normal + )) diff --git a/IPython/iplib.py b/IPython/iplib.py index 6bda4b7..af65870 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 924 2005-11-15 20:24:31Z fperez $ +$Id: iplib.py 951 2005-12-25 00:57:24Z fperez $ """ #***************************************************************************** @@ -54,7 +54,7 @@ from codeop import CommandCompiler # IPython's own modules import IPython from IPython import OInspect,PyColorize,ultraTB -from IPython.ultraTB import ColorScheme,ColorSchemeTable # too long names +from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names from IPython.Logger import Logger from IPython.Magic import Magic,magic2python,shlex_split from IPython.usage import cmd_line_usage,interactive_usage @@ -969,6 +969,14 @@ class InteractiveShell(code.InteractiveConsole, Logger, Magic): outcomps = comps.keys() outcomps.sort() return outcomps + + def set_completer_frame(self, frame): + if frame: + ns = frame.f_globals.copy() + ns.update(frame.f_locals) + self.Completer.namespace = ns + else: + self.Completer.namespace = self.user_ns def post_config_initialization(self): """Post configuration init method @@ -1441,7 +1449,7 @@ want to merge them back into the new files.""" % locals() self.write(banner) more = 0 - + # Mark activity in the builtins __builtin__.__dict__['__IPYTHON__active'] += 1 diff --git a/IPython/ultraTB.py b/IPython/ultraTB.py index 44648a1..20e6f4c 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 703 2005-08-16 17:34:44Z fperez $""" +$Id: ultraTB.py 951 2005-12-25 00:57:24Z fperez $""" #***************************************************************************** # Copyright (C) 2001 Nathaniel Gray @@ -85,8 +85,8 @@ from UserDict import UserDict from IPython import Debugger from IPython.Struct import Struct -from IPython.ColorANSI import * from IPython.genutils import Term,uniq_stable,error,info +from IPython.excolors import ExceptionColors #--------------------------------------------------------------------------- # Code begins @@ -99,131 +99,42 @@ def inspect_error(): error('Internal Python error in the inspect module.\n' 'Below is the traceback from this internal error.\n') -# Make a global variable out of the color scheme table used for coloring -# exception tracebacks. This allows user code to add new schemes at runtime. -ExceptionColors = ColorSchemeTable() - -# Populate it with color schemes -C = TermColors # shorthand and local lookup -ExceptionColors.add_scheme(ColorScheme( - 'NoColor', - # The color to be used for the top line - topline = C.NoColor, - - # The colors to be used in the traceback - filename = C.NoColor, - lineno = C.NoColor, - name = C.NoColor, - vName = C.NoColor, - val = C.NoColor, - em = C.NoColor, - - # Emphasized colors for the last frame of the traceback - normalEm = C.NoColor, - filenameEm = C.NoColor, - linenoEm = C.NoColor, - nameEm = C.NoColor, - valEm = C.NoColor, - - # Colors for printing the exception - excName = C.NoColor, - line = C.NoColor, - caret = C.NoColor, - Normal = C.NoColor - )) - -# make some schemes as instances so we can copy them for modification easily -ExceptionColors.add_scheme(ColorScheme( - 'Linux', - # The color to be used for the top line - topline = C.LightRed, - - # The colors to be used in the traceback - filename = C.Green, - lineno = C.Green, - name = C.Purple, - vName = C.Cyan, - val = C.Green, - em = C.LightCyan, - - # Emphasized colors for the last frame of the traceback - normalEm = C.LightCyan, - filenameEm = C.LightGreen, - linenoEm = C.LightGreen, - nameEm = C.LightPurple, - valEm = C.LightBlue, - - # Colors for printing the exception - excName = C.LightRed, - line = C.Yellow, - caret = C.White, - Normal = C.Normal - )) - -# For light backgrounds, swap dark/light colors -ExceptionColors.add_scheme(ColorScheme( - 'LightBG', - # The color to be used for the top line - topline = C.Red, - - # The colors to be used in the traceback - filename = C.LightGreen, - lineno = C.LightGreen, - name = C.LightPurple, - vName = C.Cyan, - val = C.LightGreen, - em = C.Cyan, - - # Emphasized colors for the last frame of the traceback - normalEm = C.Cyan, - filenameEm = C.Green, - linenoEm = C.Green, - nameEm = C.Purple, - valEm = C.Blue, - - # Colors for printing the exception - excName = C.Red, - #line = C.Brown, # brown often is displayed as yellow - line = C.Red, - caret = C.Normal, - Normal = C.Normal - )) - class TBTools: """Basic tools used by all traceback printer classes.""" - def __init__(self,color_scheme = 'NoColor',call_pdb=0): + def __init__(self,color_scheme = 'NoColor',call_pdb=False): # Whether to call the interactive pdb debugger after printing # tracebacks or not self.call_pdb = call_pdb - if call_pdb: - self.pdb = Debugger.Pdb() - else: - self.pdb = None # Create color table - self.ColorSchemeTable = ExceptionColors + self.color_scheme_table = ExceptionColors self.set_colors(color_scheme) self.old_scheme = color_scheme # save initial value for toggles + if call_pdb: + self.pdb = Debugger.Pdb(self.color_scheme_table.active_scheme_name) + else: + self.pdb = None + def set_colors(self,*args,**kw): """Shorthand access to the color table scheme selector method.""" - self.ColorSchemeTable.set_active_scheme(*args,**kw) + self.color_scheme_table.set_active_scheme(*args,**kw) # for convenience, set Colors to the active scheme - self.Colors = self.ColorSchemeTable.active_colors + self.Colors = self.color_scheme_table.active_colors def color_toggle(self): """Toggle between the currently active color scheme and NoColor.""" - if self.ColorSchemeTable.active_scheme_name == 'NoColor': - self.ColorSchemeTable.set_active_scheme(self.old_scheme) - self.Colors = self.ColorSchemeTable.active_colors + if self.color_scheme_table.active_scheme_name == 'NoColor': + self.color_scheme_table.set_active_scheme(self.old_scheme) + self.Colors = self.color_scheme_table.active_colors else: - self.old_scheme = self.ColorSchemeTable.active_scheme_name - self.ColorSchemeTable.set_active_scheme('NoColor') - self.Colors = self.ColorSchemeTable.active_colors + self.old_scheme = self.color_scheme_table.active_scheme_name + self.color_scheme_table.set_active_scheme('NoColor') + self.Colors = self.color_scheme_table.active_colors #--------------------------------------------------------------------------- class ListTB(TBTools): @@ -660,14 +571,21 @@ class VerboseTB(TBTools): if self.call_pdb: if self.pdb is None: - self.pdb = Debugger.Pdb() - # the system displayhook may have changed, restore the original for pdb + self.pdb = Debugger.Pdb( + self.color_scheme_table.active_scheme_name) + # the system displayhook may have changed, restore the original + # for pdb dhook = sys.displayhook sys.displayhook = sys.__displayhook__ self.pdb.reset() + # Find the right frame so we don't pop up inside ipython itself + etb = self.tb while self.tb.tb_next is not None: self.tb = self.tb.tb_next try: + if etb and etb.tb_next: + etb = etb.tb_next + self.pdb.botframe = etb.tb_frame self.pdb.interaction(self.tb.tb_frame, self.tb) except: print '*** ERROR ***' @@ -801,7 +719,7 @@ class AutoFormattedTB(FormattedTB): print >> out, self.text(etype, evalue, etb) self.tb_offset = tb_offset else: - print >> out, self.text() + print >> out, self.text(etype, evalue, etb) self.debugger() def text(self,etype=None,value=None,tb=None,context=5,mode=None): diff --git a/doc/ChangeLog b/doc/ChangeLog index e6d35f9..7b2c7c4 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,19 @@ +2005-12-24 Fernando Perez + + * setup.py: added download_url to setup(). This registers the + download address at PyPI, which is not only useful to humans + browsing the site, but is also picked up by setuptools (the Eggs + machinery). Thanks to Ville and R. Kern for the info/discussion + on this. + +2005-12-23 Fernando Perez + + * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. + This brings a lot of nice functionality to the pdb mode, which now + has tab-completion, syntax highlighting, and better stack handling + than before. Many thanks to Vivian De Smedt + for the original patches. + 2005-12-08 Fernando Perez * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling @@ -11,7 +27,7 @@ Fix bug where a naked 'alias' call in the ipythonrc file would cause a crash. Bug reported by Jorgen Stenarson. -2005-11-15 +2005-11-15 Fernando Perez * IPython/ipmaker.py (make_IPython): cleanups which should improve startup time. @@ -26,13 +42,13 @@ searches. Users can still select either mode at runtime on a per-search basis. -2005-11-13 +2005-11-13 Fernando Perez * IPython/wildcard.py (NameSpace.__init__): fix resolution of attributes in wildcard searches for subclasses. Modified version of a patch by Jorgen. -2005-11-12 +2005-11-12 Fernando Perez * IPython/iplib.py (embed_mainloop): Fix handling of globals for embedded instances. I added a user_global_ns attribute to the diff --git a/setup.py b/setup.py index de5a746..971bd98 100755 --- a/setup.py +++ b/setup.py @@ -133,6 +133,7 @@ setup(name = name, author = authors['Fernando'][0], author_email = authors['Fernando'][1], url = url, + download_url = download_url, license = license, platforms = platforms, keywords = keywords,