##// END OF EJS Templates
Fix bug with 2.3 and readline; clean up.
fperez -
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,54 +1,40 b''
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
13 try:
14 from readline import *
15 import readline as _rl
16 have_readline = True
17 except ImportError:
18 have_readline = False
15
19
16 if sys.platform == 'win32':
20 if sys.platform == 'win32' and have_readline:
17 try:
21 try:
18 import pyreadline.rlmain
22 _outputfile=_rl.GetOutputFile()
19 #add config for inputrcpath here:
23 except NameError:
20 #pyreadline.rlmain.config_path="c:/python/test_config.ini"
24 print "Failed GetOutputFile"
21 from readline import *
25 have_readline = False
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:
36 from readline import *
37 import readline as _rl
38 have_readline = True
39 except ImportError:
40 pass
41
42 if have_readline:
43 try:
44 _outputfile=_rl.GetOutputFile()
45 except NameError:
46 print "Failed GetOutputFile"
47 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 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now