From 343735629ed03ef12e4dc1d6f808282d1c31ba98 2006-01-08 08:29:44
From: fperez
Date: 2006-01-08 08:29:44
Subject: [PATCH] Small fix in ultraTB, and fix autocall.

Add Scott's patch (issue 48) to fix the new fix_syntax hook.

I started updating the copyright notices, but I don't really think that's
worth doing or even necessary (adding the 2006 year mark).  That's why so
many files appear changed, though the functional diff is fairly small.

---

diff --git a/IPython/ColorANSI.py b/IPython/ColorANSI.py
index b8504b7..6d82dbf 100644
--- a/IPython/ColorANSI.py
+++ b/IPython/ColorANSI.py
@@ -1,10 +1,10 @@
 # -*- coding: utf-8 -*-
 """Tools for coloring text in ANSI terminals.
 
-$Id: ColorANSI.py 951 2005-12-25 00:57:24Z fperez $"""
+$Id: ColorANSI.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
-#       Copyright (C) 2002-2004 Fernando Perez. <fperez@colorado.edu>
+#       Copyright (C) 2002-2006 Fernando Perez. <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/ConfigLoader.py b/IPython/ConfigLoader.py
index b4b1e3e..95aa0d7 100644
--- a/IPython/ConfigLoader.py
+++ b/IPython/ConfigLoader.py
@@ -1,10 +1,10 @@
 # -*- coding: utf-8 -*-
 """Configuration loader
 
-$Id: ConfigLoader.py 958 2005-12-27 23:17:51Z fperez $"""
+$Id: ConfigLoader.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
-#       Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/CrashHandler.py b/IPython/CrashHandler.py
index cdf11ef..c26b100 100644
--- a/IPython/CrashHandler.py
+++ b/IPython/CrashHandler.py
@@ -1,10 +1,10 @@
 # -*- coding: utf-8 -*-
 """sys.excepthook for IPython itself, leaves a detailed report on disk.
 
-$Id: CrashHandler.py 958 2005-12-27 23:17:51Z fperez $"""
+$Id: CrashHandler.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
-#       Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/Debugger.py b/IPython/Debugger.py
index bae4cae..0ca2037 100644
--- a/IPython/Debugger.py
+++ b/IPython/Debugger.py
@@ -15,7 +15,23 @@ details on the PSF (Python Software Foundation) standard license, see:
 
 http://www.python.org/2.2.3/license.html
 
-$Id: Debugger.py 958 2005-12-27 23:17:51Z fperez $"""
+$Id: Debugger.py 994 2006-01-08 08:29:44Z fperez $"""
+
+#*****************************************************************************
+#
+# Since this file is essentially a modified copy of the pdb module which is
+# part of the standard Python distribution, I assume that the proper procedure
+# is to maintain its copyright as belonging to the Python Software Foundation
+# (in addition to my own, for all new code).
+#
+#       Copyright (C) 2001 Python Software Foundation, www.python.org
+#       Copyright (C) 2005-2006 Fernando Perez. <fperez@colorado.edu>
+#
+#  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']
diff --git a/IPython/Extensions/InterpreterExec.py b/IPython/Extensions/InterpreterExec.py
index 4204b7d..3662617 100644
--- a/IPython/Extensions/InterpreterExec.py
+++ b/IPython/Extensions/InterpreterExec.py
@@ -5,11 +5,11 @@ We define a special input line filter to allow typing lines which begin with
 '~', '/' or '.'. If one of those strings is encountered, it is automatically
 executed.
 
-$Id: InterpreterExec.py 638 2005-07-18 03:01:41Z fperez $"""
+$Id: InterpreterExec.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
 #       Copyright (C) 2004 W.J. van der Laan <gnufnork@hetdigitalegat.nl>
-#       Copyright (C) 2004 Fernando Perez <fperez@colorado.edu>
+#       Copyright (C) 2004-2006 Fernando Perez <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/Extensions/InterpreterPasteInput.py b/IPython/Extensions/InterpreterPasteInput.py
index fb325fe..4c2f77d 100644
--- a/IPython/Extensions/InterpreterPasteInput.py
+++ b/IPython/Extensions/InterpreterPasteInput.py
@@ -33,7 +33,7 @@ only sees the real part of the code.
 All other input is processed normally.
 """
 #*****************************************************************************
-#       Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/Logger.py b/IPython/Logger.py
index 989ec15..03a3612 100644
--- a/IPython/Logger.py
+++ b/IPython/Logger.py
@@ -2,12 +2,12 @@
 """
 Logger class for IPython's logging facilities.
 
-$Id: Logger.py 988 2006-01-02 21:21:47Z fperez $
+$Id: Logger.py 994 2006-01-08 08:29:44Z fperez $
 """
 
 #*****************************************************************************
 #       Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
-#       Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/Magic.py b/IPython/Magic.py
index 91aab14..49ed450 100644
--- a/IPython/Magic.py
+++ b/IPython/Magic.py
@@ -1,11 +1,11 @@
 # -*- coding: utf-8 -*-
 """Magic functions for InteractiveShell.
 
-$Id: Magic.py 991 2006-01-04 18:15:34Z fperez $"""
+$Id: Magic.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
 #       Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
-#       Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
@@ -56,6 +56,7 @@ def on_off(tag):
     """Return an ON/OFF string for a 1/0 input. Simple utility function."""
     return ['OFF','ON'][tag]
 
+class Bunch: pass
 
 #***************************************************************************
 # Main class implementing Magic functionality
@@ -84,6 +85,9 @@ class Magic:
             self.magic_prun = self.profile_missing_notice
         self.shell = shell
 
+        # namespace for holding state we may need
+        self._magic_state = Bunch()
+
     def profile_missing_notice(self, *args, **kwargs):
         error("""\
 The profile module could not be found.  If you are a Debian user,
@@ -424,11 +428,36 @@ Currently the magic system has the following functions:\n"""
     def magic_autocall(self, parameter_s = ''):
         """Make functions callable without having to type parentheses.
 
-        This cycles the autocall command line through its three valid values
-        (0->Off, 1->Smart, 2->Full)"""
+        Usage:
+
+           %autocall [mode]
+
+        The mode can be one of: 0->Off, 1->Smart, 2->Full.  If not given, the
+        value is toggled on and off (remembering the previous state)."""
         
         rc = self.shell.rc
-        rc.autocall = not rc.autocall
+
+        if parameter_s:
+            arg = int(parameter_s)
+        else:
+            arg = 'toggle'
+
+        if not arg in (0,1,2,'toggle'):
+            error('Valid modes: (0->Off, 1->Smart, 2->Full')
+            return
+
+        if arg in (0,1,2):
+            rc.autocall = arg
+        else: # toggle
+            if rc.autocall:
+                self._magic_state.autocall_save = rc.autocall
+                rc.autocall = 0
+            else:
+                try:
+                    rc.autocall = self._magic_state.autocall_save
+                except AttributeError:
+                    rc.autocall = self._magic_state.autocall_save = 1
+                
         print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
 
     def magic_autoindent(self, parameter_s = ''):
diff --git a/IPython/Prompts.py b/IPython/Prompts.py
index 07be7e8..0dc313a 100644
--- a/IPython/Prompts.py
+++ b/IPython/Prompts.py
@@ -2,10 +2,10 @@
 """
 Classes for handling input/output prompts.
 
-$Id: Prompts.py 975 2005-12-29 23:50:22Z fperez $"""
+$Id: Prompts.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
-#       Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/Release.py b/IPython/Release.py
index 2ca2f2f..72933d8 100644
--- a/IPython/Release.py
+++ b/IPython/Release.py
@@ -1,10 +1,10 @@
 # -*- coding: utf-8 -*-
 """Release data for the IPython project.
 
-$Id: Release.py 992 2006-01-04 18:35:40Z fperez $"""
+$Id: Release.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
-#       Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
 #
 #       Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
 #       <n8gray@caltech.edu>
@@ -24,7 +24,7 @@ name = 'ipython'
 
 version = '0.7.0.rc8'
 
-revision = '$Revision: 992 $'
+revision = '$Revision: 994 $'
 
 description = "An enhanced interactive Python shell."
 
diff --git a/IPython/Shell.py b/IPython/Shell.py
index 67f3655..7e58fb3 100644
--- a/IPython/Shell.py
+++ b/IPython/Shell.py
@@ -4,10 +4,10 @@
 All the matplotlib support code was co-developed with John Hunter,
 matplotlib's author.
 
-$Id: Shell.py 993 2006-01-04 19:51:01Z fperez $"""
+$Id: Shell.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
-#       Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/background_jobs.py b/IPython/background_jobs.py
index 904dc10..c9c3aa3 100644
--- a/IPython/background_jobs.py
+++ b/IPython/background_jobs.py
@@ -18,11 +18,11 @@ http://folk.uio.no/hpl/scripting
 (although ultimately no code from this text was used, as IPython's system is a
 separate implementation).
 
-$Id: background_jobs.py 958 2005-12-27 23:17:51Z fperez $
+$Id: background_jobs.py 994 2006-01-08 08:29:44Z fperez $
 """
 
 #*****************************************************************************
-#       Copyright (C) 2005 Fernando Perez <fperez@colorado.edu>
+#       Copyright (C) 2005-2006 Fernando Perez <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/completer.py b/IPython/completer.py
index f205eda..99e808a 100644
--- a/IPython/completer.py
+++ b/IPython/completer.py
@@ -56,7 +56,7 @@ used, and this module (and the readline module) are silently inactive.
 # Software Foundation (in addition to my own, for all new code).
 #
 #       Copyright (C) 2001 Python Software Foundation, www.python.org
-#       Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/demo.py b/IPython/demo.py
index d1ed570..77cb546 100644
--- a/IPython/demo.py
+++ b/IPython/demo.py
@@ -100,7 +100,7 @@ WARNING: this module uses Python 2.3 features, so it won't work in 2.2
 environments.
 """
 #*****************************************************************************
-#       Copyright (C) 2005 Fernando Perez. <Fernando.Perez@colorado.edu>
+#     Copyright (C) 2005-2006 Fernando Perez. <Fernando.Perez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/excolors.py b/IPython/excolors.py
index 785fc70..068f2b6 100644
--- a/IPython/excolors.py
+++ b/IPython/excolors.py
@@ -5,7 +5,7 @@ Color schemes for exception handling code in IPython.
 $Id: Prompts.py 638 2005-07-18 03:01:41Z fperez $"""
 
 #*****************************************************************************
-#       Copyright (C) 2005 Fernando Perez <fperez@colorado.edu>
+#       Copyright (C) 2005-2006 Fernando Perez <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/genutils.py b/IPython/genutils.py
index c2e5f04..4655b17 100644
--- a/IPython/genutils.py
+++ b/IPython/genutils.py
@@ -5,10 +5,10 @@ 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 990 2006-01-04 06:59:02Z fperez $"""
+$Id: genutils.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
-#       Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/iplib.py b/IPython/iplib.py
index 0ba8abd..e6c61cc 100644
--- a/IPython/iplib.py
+++ b/IPython/iplib.py
@@ -6,12 +6,12 @@ Requires Python 2.1 or newer.
 
 This file contains all the classes and helper functions specific to IPython.
 
-$Id: iplib.py 993 2006-01-04 19:51:01Z fperez $
+$Id: iplib.py 994 2006-01-08 08:29:44Z fperez $
 """
 
 #*****************************************************************************
 #       Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
-#       Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
@@ -75,6 +75,8 @@ from IPython.background_jobs import BackgroundJobManager
 from IPython.usage import cmd_line_usage,interactive_usage
 from IPython.genutils import *
 
+# Globals
+
 # store the builtin raw_input globally, and use this always, in case user code
 # overwrites it (like wx.py.PyShell does)
 raw_input_original = raw_input
@@ -83,6 +85,7 @@ raw_input_original = raw_input
 ini_spaces_re = re.compile(r'^(\s+)')
 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
 
+
 #****************************************************************************
 # Some utility function definitions
 
@@ -100,13 +103,12 @@ def softspace(file, newvalue):
         pass
     return oldvalue
 
-#****************************************************************************
-
 
 #****************************************************************************
 # Local use exceptions
 class SpaceInInput(exceptions.Exception): pass
 
+
 #****************************************************************************
 # Local use classes
 class Bunch: pass
@@ -1183,7 +1185,15 @@ want to merge them back into the new files.""" % locals()
                 return False
         except EOFError:
             return False
-        self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg)
+
+        def int0(x):
+            try:
+                return int(x)
+            except TypeError:
+                return 0
+        # always pass integer line and offset values to editor hook
+        self.hooks.fix_error_editor(e.filename,
+            int0(e.lineno),int0(e.offset),e.msg)
         return True
         
     def edit_syntax_error(self):
diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py
index 22454ae..cfff7f5 100644
--- a/IPython/ipmaker.py
+++ b/IPython/ipmaker.py
@@ -6,10 +6,10 @@ Requires Python 2.1 or better.
 
 This file contains the main make_IPython() starter function.
 
-$Id: ipmaker.py 990 2006-01-04 06:59:02Z fperez $"""
+$Id: ipmaker.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
-#       Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
+#       Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
 #
 #  Distributed under the terms of the BSD License.  The full license is in
 #  the file COPYING, distributed as part of this software.
diff --git a/IPython/ultraTB.py b/IPython/ultraTB.py
index fff5757..9b0ad15 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 992 2006-01-04 18:35:40Z fperez $"""
+$Id: ultraTB.py 994 2006-01-08 08:29:44Z fperez $"""
 
 #*****************************************************************************
 #       Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu>
@@ -140,7 +140,6 @@ def _fixed_getinnerframes(etb, context=1,tb_offset=0):
             lines = (['\n'] * -maybeStart) + lines
         if len(lines) < context:
             lines += ['\n'] * (context - len(lines))
-        assert len(lines) == context
         buf = list(records[i])
         buf[LNUM_POS] = lnum
         buf[INDEX_POS] = lnum - 1 - start
diff --git a/IPython/winconsole.py b/IPython/winconsole.py
index 8c0824f..91cb26c 100644
--- a/IPython/winconsole.py
+++ b/IPython/winconsole.py
@@ -1,9 +1,12 @@
+"""Set of functions to work with console on Windows.
 """
-Set of functions to work with console on Windows.
 
-Author: Alexander Belchenko (e-mail: bialix AT ukr.net)
-License: Public domain
-"""
+#*****************************************************************************
+#       Copyright (C) 2005 Alexander Belchenko <bialix@ukr.net>
+#
+#                This file is placed in the public domain.
+#
+#*****************************************************************************
 
 __author__  = 'Alexander Belchenko (e-mail: bialix AT ukr.net)'
 __license__ = 'Public domain'
diff --git a/doc/ChangeLog b/doc/ChangeLog
index e6c390a..de732f8 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,17 @@
+2006-01-08  Fernando Perez  <Fernando.Perez@colorado.edu>
+
+	* IPython/Magic.py (magic_autocall): Fix %autocall magic.  Now
+	it can be used as a (stateful) toggle, or with a direct parameter.
+
+	* IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
+	could be triggered in certain cases and cause the traceback
+	printer not to work.
+
+2006-01-07  Fernando Perez  <Fernando.Perez@colorado.edu>
+
+	* IPython/iplib.py (_should_recompile): Small fix, closes
+	http://www.scipy.net/roundup/ipython/issue48.  Patch by Scott.
+
 2006-01-04  Fernando Perez  <Fernando.Perez@colorado.edu>
 
 	* IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK