From ef7b1b53b07cf240dda89583b7c13887609a3cc9 2006-05-25 07:47:56 From: fperez Date: 2006-05-25 07:47:56 Subject: [PATCH] Small fix to sys.argv, match python's default behavior. --- diff --git a/IPython/__init__.py b/IPython/__init__.py index 9d6e266..1f70fad 100644 --- a/IPython/__init__.py +++ b/IPython/__init__.py @@ -27,10 +27,10 @@ IPython tries to: IPython requires Python 2.3 or newer. -$Id: __init__.py 1314 2006-05-19 18:24:14Z fperez $""" +$Id: __init__.py 1328 2006-05-25 07:47:56Z fperez $""" #***************************************************************************** -# Copyright (C) 2001-2004 Fernando Perez. +# Copyright (C) 2001-2006 Fernando Perez. # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. @@ -40,14 +40,13 @@ $Id: __init__.py 1314 2006-05-19 18:24:14Z fperez $""" import sys if sys.version[0:3] < '2.3': - raise ImportError, 'Python Version 2.3 or above is required.' + raise ImportError('Python Version 2.3 or above is required for IPython.') # Make it easy to import extensions - they are always directly on pythonpath. # Therefore, non-IPython modules can be added to Extensions directory - import os sys.path.append(os.path.dirname(__file__) + "/Extensions") - + # Define what gets imported with a 'from IPython import *' __all__ = ['deep_reload','genutils','ipstruct','ultraTB','DPyGetOpt', 'Itpl','hooks','ConfigLoader','OutputTrap','Release','Shell', diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py index b9bc197..4a7eaa0 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 1324 2006-05-24 20:25:11Z fperez $""" +$Id: ipmaker.py 1328 2006-05-25 07:47:56Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez. @@ -329,6 +329,11 @@ object? -> Details about 'object'. ?object also works, ?? prints more. mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'), qw('classic profile'),qw('classic rcfile')]) + # Fix up sys.argv to omit the ipython call, for consistency with how + # Python itself operates (the inconsistency can break user scripts which + # rely on the Python behavior when run under ipython). + sys.argv[:] = sys.argv[1:] + #--------------------------------------------------------------------------- # Log replay diff --git a/doc/ChangeLog b/doc/ChangeLog index 9dedde4..1e27423 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,9 @@ -2006-05-24 Fernando Perez +2006-05-25 Fernando Perez + + * IPython/ipmaker.py (make_IPython): remove the ipython call path + from sys.argv, to be 100% consistent with how Python itself works + (as seen for example with python -i file.py). After a bug report + by Jeffrey Collins. * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix nasty bug which was preventing custom namespaces with -pylab,