From 116d729baf08cc3ebb221c710ed2913d1c4c95c4 2005-09-06 03:49:12 From: fperez Date: 2005-09-06 03:49:12 Subject: [PATCH] Close issue 41, remove obsolete gtk 1.x code, trap os.getcwd exceptions at init time. --- diff --git a/IPython/Shell.py b/IPython/Shell.py index 35ec3eb..e24bd65 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 703 2005-08-16 17:34:44Z fperez $""" +$Id: Shell.py 802 2005-09-06 03:49:12Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez @@ -561,9 +561,6 @@ def hijack_gtk(): """Modifies pyGTK's mainloop with a dummy so user code does not block IPython. This function returns the original `gtk.mainloop` function that has been hijacked. - - NOTE: Make sure you import this *AFTER* you call - pygtk.require(...). """ def dummy_mainloop(*args, **kw): pass @@ -592,8 +589,6 @@ class IPShellGTK(threading.Thread): def __init__(self,argv=None,user_ns=None,debug=1, shell_class=MTInteractiveShell): - import pygtk - pygtk.require("2.0") import gtk self.gtk = gtk diff --git a/IPython/iplib.py b/IPython/iplib.py index 8ef9c16..2efc4f2 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 774 2005-09-01 00:27:53Z fperez $ +$Id: iplib.py 802 2005-09-06 03:49:12Z fperez $ """ #***************************************************************************** @@ -590,7 +590,10 @@ class InteractiveShell(code.InteractiveConsole, Logger, Magic): self.input_hist = InputList(['\n']) # list of visited directories - self.dir_hist = [os.getcwd()] + try: + self.dir_hist = [os.getcwd()] + except IOError, e: + self.dir_hist = [] # dict of output history self.output_hist = {} @@ -600,11 +603,14 @@ class InteractiveShell(code.InteractiveConsole, Logger, Magic): # number of positional arguments of the alias. self.alias_table = {} - # dict of things NOT to alias (keywords and builtins) - self.no_alias = {} - for key in keyword.kwlist: - self.no_alias[key] = 1 - self.no_alias.update(__builtin__.__dict__) + # dict of things NOT to alias (keywords, builtins and some special magics) + no_alias = {} + no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias'] + for key in keyword.kwlist + no_alias_magics: + no_alias[key] = 1 + no_alias.update(__builtin__.__dict__) + self.no_alias = no_alias + # make global variables for user access to these self.user_ns['_ih'] = self.input_hist @@ -953,7 +959,7 @@ class InteractiveShell(code.InteractiveConsole, Logger, Magic): In particular, make sure no Python keywords/builtins are in it.""" no_alias = self.no_alias - for k in self.alias_table.keys(): + for k in self.alias_table: if k in no_alias: del self.alias_table[k] if verbose: diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py index c824fe6..75fe3d2 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 638 2005-07-18 03:01:41Z fperez $""" +$Id: ipmaker.py 802 2005-09-06 03:49:12Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez. @@ -194,9 +194,9 @@ object? -> Details about 'object'. ?object also works, ?? prints more. pdb = 0, pprint = 0, profile = '', - prompt_in1 = 'In [\\#]:', - prompt_in2 = ' .\\D.:', - prompt_out = 'Out[\\#]:', + prompt_in1 = 'In [\\#]: ', + prompt_in2 = ' .\\D.: ', + prompt_out = 'Out[\\#]: ', prompts_pad_left = 1, quick = 0, readline = 1, diff --git a/doc/ChangeLog b/doc/ChangeLog index b4d7747..02f0fa1 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,16 @@ +2005-09-05 Fernando Perez + + * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") + calls. These were a leftover from the GTK 1.x days, and can cause + problems in certain cases (after a report by John Hunter). + + * IPython/iplib.py (InteractiveShell.__init__): Trap exception if + os.getcwd() fails at init time. Thanks to patch from David Remahl + . + (InteractiveShell.__init__): prevent certain special magics from + being shadowed by aliases. Closes + http://www.scipy.net/roundup/ipython/issue41. + 2005-08-31 Fernando Perez * IPython/iplib.py (InteractiveShell.complete): Added new