##// END OF EJS Templates
Fix bug with 2.3 and readline; clean up.
fperez -
Show More
@@ -1,54 +1,40
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """ Imports and provides the "correct" version of readline for the platform.
2 """ Imports and provides the 'correct' version of readline for the platform.
3
3
4 Readline is used throughout IPython as "import IPython.rlineimpl as readline.
4 Readline is used throughout IPython as 'import IPython.rlineimpl as readline'.
5
5
6 In addition to normal readline stuff, this module provides have_readline boolean
6 In addition to normal readline stuff, this module provides have_readline
7 and _outputfile variable used in genutils.
7 boolean and _outputfile variable used in genutils.
8
8
9 $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $"""
9 $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $"""
10
10
11
12 import sys
11 import sys
13
12
14 have_readline = False
15
16 if sys.platform == 'win32':
17 try:
18 import pyreadline.rlmain
19 #add config for inputrcpath here:
20 #pyreadline.rlmain.config_path="c:/python/test_config.ini"
21 from readline import *
22 #print "Using the new pyreadline (thanks for participating in the testing!)"
23
24 have_readline = True
25
26 import readline as _rl
27 except ImportError:
28 #print "IPython team recommends the new pyreadline for Windows use, "
29 #print "It's superior especially with non-US keyboard layouts."
30 #print "Try installing it with 'easy_install pyreadline (ctypes is required) or"
31 #print "svn co http://ipython.scipy.org/svn/ipython/pyreadline/trunk pyreadline"
32 #print "Trying 'old' windows readline."
33 #print "Using 'old' readline, you might want to try pyreadline:"
34 #print "http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro"
35 try:
13 try:
36 from readline import *
14 from readline import *
37 import readline as _rl
15 import readline as _rl
38 have_readline = True
16 have_readline = True
39 except ImportError:
17 except ImportError:
40 pass
18 have_readline = False
41
19
42 if have_readline:
20 if sys.platform == 'win32' and have_readline:
43 try:
21 try:
44 _outputfile=_rl.GetOutputFile()
22 _outputfile=_rl.GetOutputFile()
45 except NameError:
23 except NameError:
46 print "Failed GetOutputFile"
24 print "Failed GetOutputFile"
47 have_readline = False
25 have_readline = False
48
26
49 else:
27 # the clear_history() function was only introduced in Python 2.4 and is
28 # actually optional in the readline API, so we must explicitly check for its
29 # existence. Some known platforms actually don't have it. This thread:
30 # http://mail.python.org/pipermail/python-dev/2003-August/037845.html
31 # has the original discussion.
32
33 if have_readline:
34 import readline
50 try:
35 try:
51 from readline import *
36 readline.clear_history
52 have_readline = True
37 except AttributeError:
53 except ImportError:
38 def clear_history(): pass
54 pass
39 readline.clear_history = clear_history
40 del readline
@@ -1,5 +1,10
1 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu>
1 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/rlineimpl.py: check for clear_history in readline and
4 make it a dummy no-op if not available. This function isn't
5 guaranteed to be in the API and appeared in Python 2.4, so we need
6 to check it ourselves. Also, clean up this file quite a bit.
7
3 * ipython.1: update man page and full manual with information
8 * ipython.1: update man page and full manual with information
4 about threads (remove outdated warning). Closes #151.
9 about threads (remove outdated warning). Closes #151.
5
10
General Comments 0
You need to be logged in to leave comments. Login now