diff --git a/IPython/Magic.py b/IPython/Magic.py index f7105a5..7fa859f 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 2187 2007-03-30 04:56:40Z fperez $""" +$Id: Magic.py 2190 2007-03-30 18:35:46Z fperez $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -671,8 +671,11 @@ Currently the magic system has the following functions:\n""" This function is meant to be called by pdef, pdoc & friends.""" + #oname = oname.strip() + #print '1- oname: <%r>' % oname # dbg try: oname = oname.strip().encode('ascii') + #print '2- oname: <%r>' % oname # dbg except UnicodeEncodeError: print 'Python identifiers can only contain ascii characters.' return 'not found' @@ -846,6 +849,11 @@ Currently the magic system has the following functions:\n""" Show objects beginning with a single _: %psearch -a _* list objects beginning with a single underscore""" + try: + parameter_s = parameter_s.encode('ascii') + except UnicodeEncodeError: + print 'Python identifiers can only contain ascii characters.' + return # default namespaces to be searched def_search = ['user','builtin'] @@ -855,7 +863,7 @@ Currently the magic system has the following functions:\n""" opt = opts.get shell = self.shell psearch = shell.inspector.psearch - + # select case options if opts.has_key('i'): ignore_case = True diff --git a/IPython/genutils.py b/IPython/genutils.py index 09ab0b4..0247aed 100644 --- a/IPython/genutils.py +++ b/IPython/genutils.py @@ -5,7 +5,7 @@ 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 2154 2007-03-19 00:10:07Z fperez $""" +$Id: genutils.py 2190 2007-03-30 18:35:46Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez. @@ -265,7 +265,14 @@ def arg_split(s,posix=False): This is a modified version of the standard library's shlex.split() function, but with a default of posix=False for splitting, so that quotes in inputs are respected.""" - + + # XXX - there may be unicode-related problems here!!! I'm not sure that + # shlex is truly unicode-safe, so it might be necessary to do + # + # s = s.encode(sys.stdin.encoding) + # + # first, to ensure that shlex gets a normal string. Input from anyone who + # knows more about unicode and shlex than I would be good to have here... lex = shlex.shlex(s, posix=posix) lex.whitespace_split = True return list(lex) diff --git a/IPython/iplib.py b/IPython/iplib.py index 73caca6..deffb67 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.3 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 2187 2007-03-30 04:56:40Z fperez $ +$Id: iplib.py 2190 2007-03-30 18:35:46Z fperez $ """ #***************************************************************************** @@ -1984,6 +1984,7 @@ want to merge them back into the new files.""" % locals() try: line = raw_input_original(prompt).decode(sys.stdin.encoding) + #line = raw_input_original(prompt) except ValueError: warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!") self.exit_now = True diff --git a/doc/ChangeLog b/doc/ChangeLog index 0d45e5d..6174f60 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2007-03-30 Fernando Perez + + * IPython/Magic.py (magic_psearch): add unicode support by + encoding to ascii the input, since this routine also only deals + with valid Python names. Fixes a bug reported by Stefan. + 2007-03-29 Fernando Perez * IPython/Magic.py (_inspect): convert unicode input into ascii