From f072f38c25acdb13ce125774a71c73b8344de5e7 2006-05-24 20:25:11 From: fperez Date: 2006-05-24 20:25:11 Subject: [PATCH] - set the default value of autoedit_syntax to be false. Too many complaints. - fix pdb tracking for emacs. --- diff --git a/IPython/Debugger.py b/IPython/Debugger.py index d04075f..fe7a785 100644 --- a/IPython/Debugger.py +++ b/IPython/Debugger.py @@ -15,7 +15,7 @@ details on the PSF (Python Software Foundation) standard license, see: http://www.python.org/2.2.3/license.html -$Id: Debugger.py 1029 2006-01-18 07:33:38Z fperez $""" +$Id: Debugger.py 1324 2006-05-24 20:25:11Z fperez $""" #***************************************************************************** # @@ -32,7 +32,6 @@ $Id: Debugger.py 1029 2006-01-18 07:33:38Z fperez $""" # #***************************************************************************** - from IPython import Release __author__ = '%s <%s>' % Release.authors['Fernando'] __license__ = 'Python' @@ -63,7 +62,6 @@ def _file_lines(fname): outfile.close() return out - class Pdb(pdb.Pdb): """Modified Pdb class, does not load readline.""" @@ -113,28 +111,23 @@ class Pdb(pdb.Pdb): """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: @@ -142,22 +135,20 @@ class Pdb(pdb.Pdb): 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 = "" + 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_call = '%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) @@ -169,7 +160,7 @@ class Pdb(pdb.Pdb): rv = frame.f_locals['__return__'] #return_value += '->' return_value += repr.repr(rv) + '\n' - ret += return_value + ret.append(return_value) #s = filename + '(' + `lineno` + ')' filename = self.canonic(frame.f_code.co_filename) @@ -187,9 +178,10 @@ class Pdb(pdb.Pdb): else: args = '()' call = tpl_call % (func, args) - - level = '%s %s\n' % (link, call) - ret += level + + # The level info should be generated in the same format pdb uses, to + # avoid breaking the pdbtrack functionality of python-mode in *emacs. + ret.append('> %s(%s)%s\n' % (link,lineno,call)) start = lineno - 1 - context//2 lines = linecache.getlines(filename) @@ -197,15 +189,13 @@ class Pdb(pdb.Pdb): 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 + for i,line in enumerate(lines): + show_arrow = (start + 1 + i == lineno) + ret.append(self.__format_line(tpl_line_em, filename, + start + 1 + i, line, + arrow = show_arrow) ) + return ''.join(ret) def __format_line(self, tpl_line, filename, lineno, line, arrow = False): bp_mark = "" @@ -242,7 +232,6 @@ class Pdb(pdb.Pdb): line = tpl_line % (bp_mark_color + bp_mark, num, line) return line - def do_list(self, arg): self.lastcmd = 'list' diff --git a/IPython/UserConfig/ipy_user_conf.py b/IPython/UserConfig/ipy_user_conf.py index 936cc30..d552567 100644 --- a/IPython/UserConfig/ipy_user_conf.py +++ b/IPython/UserConfig/ipy_user_conf.py @@ -28,4 +28,3 @@ def main(): #o.autocall = 1 main() - diff --git a/IPython/UserConfig/ipythonrc b/IPython/UserConfig/ipythonrc index c22472e..9de6488 100644 --- a/IPython/UserConfig/ipythonrc +++ b/IPython/UserConfig/ipythonrc @@ -1,5 +1,5 @@ # -*- Mode: Shell-Script -*- Not really, but shows comments correctly -# $Id: ipythonrc 1155 2006-02-12 01:21:00Z fperez $ +# $Id: ipythonrc 1324 2006-05-24 20:25:11Z fperez $ #*************************************************************************** # @@ -87,7 +87,7 @@ autocall 1 # a file with syntax errors in it. If this variable is true, IPython will ask # you whether to re-open the editor immediately to correct such an error. -autoedit_syntax 1 +autoedit_syntax 0 # Auto-indent. IPython can recognize lines ending in ':' and indent the next # line, while also un-indenting automatically after 'raise' or 'return'. diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py index f75be61..b9bc197 100644 --- a/IPython/ipmaker.py +++ b/IPython/ipmaker.py @@ -6,7 +6,7 @@ Requires Python 2.1 or better. This file contains the main make_IPython() starter function. -$Id: ipmaker.py 1260 2006-04-11 10:19:34Z vivainio $""" +$Id: ipmaker.py 1324 2006-05-24 20:25:11Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez. @@ -181,8 +181,8 @@ object? -> Details about 'object'. ?object also works, ?? prints more. # Set sensible command line defaults. # This should have everything from cmdline_opts and cmdline_only opts_def = Struct(autocall = 1, - autoedit_syntax = 1, - autoindent=0, + autoedit_syntax = 0, + autoindent = 0, automagic = 1, banner = 1, cache_size = 1000, diff --git a/doc/ChangeLog b/doc/ChangeLog index 7842b56..17c1c6b 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,18 @@ 2006-05-24 Fernando Perez + * ipython.el: fix the py-pdbtrack-input-prompt variable so that + python-mode recognizes our debugger mode. + + * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of + tracebacks when walking the stack so that the stack tracking system + in emacs' python-mode can identify the frames correctly. + + * IPython/ipmaker.py (make_IPython): make the internal (and + default config) autoedit_syntax value false by default. Too many + users have complained to me (both on and off-list) about problems + with this option being on by default, so I'm making it default to + off. It can still be enabled by anyone via the usual mechanisms. + * IPython/completer.py (Completer.attr_matches): add support for PyCrust-style _getAttributeNames magic method. Patch contributed by . Closes #50. diff --git a/doc/ipython.el b/doc/ipython.el index 6a71230..9eb3c22 100644 --- a/doc/ipython.el +++ b/doc/ipython.el @@ -6,7 +6,7 @@ ;; URL: http://ipython.scipy.org ;; Compatibility: Emacs21, XEmacs21 ;; FIXME: #$@! INPUT RING -(defconst ipython-version "$Revision: 1211 $" +(defconst ipython-version "$Revision: 1324 $" "VC version number.") ;;; Commentary @@ -47,8 +47,8 @@ ;; ------------------------- ;; ;; - IMO the best feature by far of the ipython/emacs combo is how much easier it -;; makes it to find and fix bugs thanks to the ``@pdb on``/ pdbtrack combo. Try -;; it: first in the ipython to shell do ``@pdb on`` then do something that will +;; makes it to find and fix bugs thanks to the ``%pdb on``/ pdbtrack combo. Try +;; it: first in the ipython to shell do ``%pdb on`` then do something that will ;; raise an exception (FIXME nice example) -- and be amazed how easy it is to ;; inspect the live objects in each stack frames and to jump to the ;; corresponding sourcecode locations as you walk up and down the stack trace @@ -177,7 +177,9 @@ the second for a 'normal' command, and the third for a multiline command.") (define-key py-shell-map [tab] 'ipython-complete) ;;XXX this is really just a cheap hack, it only completes symbols in the ;;interactive session -- useful nonetheless. - (define-key py-mode-map [(meta tab)] 'ipython-complete)) + (define-key py-mode-map [(meta tab)] 'ipython-complete) + + ) (add-hook 'py-shell-hook 'ipython-shell-hook) ;; Regular expression that describes tracebacks for IPython in context and ;; verbose mode. @@ -191,9 +193,13 @@ the second for a 'normal' command, and the third for a multiline command.") ;; (XXX: should ask Fernando for a change) ;;"^ File \"\\(.*?\\)\", line \\([0-9]+\\).*\n.*\n.*\nSyntaxError:" ;;^ File \"\\(.*?\\)\", line \\([0-9]+\\)" + (setq py-traceback-line-re "\\(^[^\t ].+?\\.py\\).*\n +[0-9]+[^\00]*?\n-+> \\([0-9]+\\) +") - + + ;; Recognize the ipython pdb, whose prompt is 'ipdb>' instead of '(Pdb)' + (setq py-pdbtrack-input-prompt "\n[(<]*[Ii]?[Pp]db[>)]+ ") + (setq py-shell-input-prompt-1-regexp "^In \\[[0-9]+\\]: *" py-shell-input-prompt-2-regexp "^ [.][.][.]+: *" ) ;; select a suitable color-scheme