##// END OF EJS Templates
- Fix unicode bug in %psearch reported by Stefan.
fperez -
Show More
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 2187 2007-03-30 04:56:40Z fperez $"""
4 $Id: Magic.py 2190 2007-03-30 18:35:46Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -671,8 +671,11 b' Currently the magic system has the following functions:\\n"""'
671
671
672 This function is meant to be called by pdef, pdoc & friends."""
672 This function is meant to be called by pdef, pdoc & friends."""
673
673
674 #oname = oname.strip()
675 #print '1- oname: <%r>' % oname # dbg
674 try:
676 try:
675 oname = oname.strip().encode('ascii')
677 oname = oname.strip().encode('ascii')
678 #print '2- oname: <%r>' % oname # dbg
676 except UnicodeEncodeError:
679 except UnicodeEncodeError:
677 print 'Python identifiers can only contain ascii characters.'
680 print 'Python identifiers can only contain ascii characters.'
678 return 'not found'
681 return 'not found'
@@ -846,6 +849,11 b' Currently the magic system has the following functions:\\n"""'
846 Show objects beginning with a single _:
849 Show objects beginning with a single _:
847
850
848 %psearch -a _* list objects beginning with a single underscore"""
851 %psearch -a _* list objects beginning with a single underscore"""
852 try:
853 parameter_s = parameter_s.encode('ascii')
854 except UnicodeEncodeError:
855 print 'Python identifiers can only contain ascii characters.'
856 return
849
857
850 # default namespaces to be searched
858 # default namespaces to be searched
851 def_search = ['user','builtin']
859 def_search = ['user','builtin']
@@ -855,7 +863,7 b' Currently the magic system has the following functions:\\n"""'
855 opt = opts.get
863 opt = opts.get
856 shell = self.shell
864 shell = self.shell
857 psearch = shell.inspector.psearch
865 psearch = shell.inspector.psearch
858
866
859 # select case options
867 # select case options
860 if opts.has_key('i'):
868 if opts.has_key('i'):
861 ignore_case = True
869 ignore_case = True
@@ -5,7 +5,7 b' General purpose utilities.'
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 2154 2007-03-19 00:10:07Z fperez $"""
8 $Id: genutils.py 2190 2007-03-30 18:35:46Z fperez $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -265,7 +265,14 b' def arg_split(s,posix=False):'
265 This is a modified version of the standard library's shlex.split()
265 This is a modified version of the standard library's shlex.split()
266 function, but with a default of posix=False for splitting, so that quotes
266 function, but with a default of posix=False for splitting, so that quotes
267 in inputs are respected."""
267 in inputs are respected."""
268
268
269 # XXX - there may be unicode-related problems here!!! I'm not sure that
270 # shlex is truly unicode-safe, so it might be necessary to do
271 #
272 # s = s.encode(sys.stdin.encoding)
273 #
274 # first, to ensure that shlex gets a normal string. Input from anyone who
275 # knows more about unicode and shlex than I would be good to have here...
269 lex = shlex.shlex(s, posix=posix)
276 lex = shlex.shlex(s, posix=posix)
270 lex.whitespace_split = True
277 lex.whitespace_split = True
271 return list(lex)
278 return list(lex)
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.'
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 2187 2007-03-30 04:56:40Z fperez $
9 $Id: iplib.py 2190 2007-03-30 18:35:46Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -1984,6 +1984,7 b' want to merge them back into the new files.""" % locals()'
1984
1984
1985 try:
1985 try:
1986 line = raw_input_original(prompt).decode(sys.stdin.encoding)
1986 line = raw_input_original(prompt).decode(sys.stdin.encoding)
1987 #line = raw_input_original(prompt)
1987 except ValueError:
1988 except ValueError:
1988 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1989 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1989 self.exit_now = True
1990 self.exit_now = True
@@ -1,3 +1,9 b''
1 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Magic.py (magic_psearch): add unicode support by
4 encoding to ascii the input, since this routine also only deals
5 with valid Python names. Fixes a bug reported by Stefan.
6
1 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
7 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
2
8
3 * IPython/Magic.py (_inspect): convert unicode input into ascii
9 * IPython/Magic.py (_inspect): convert unicode input into ascii
General Comments 0
You need to be logged in to leave comments. Login now