##// END OF EJS Templates
fixed rlineimpl to work properly with py2exed pyreadline
vivainio -
Show More
@@ -1,40 +1,43 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
6 In addition to normal readline stuff, this module provides have_readline
7 boolean 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 import sys
11 import sys
12
12
13 try:
13 try:
14 from readline import *
14 from readline import *
15 import readline as _rl
15 import readline as _rl
16 have_readline = True
16 have_readline = True
17 except ImportError:
17 except ImportError:
18 have_readline = False
18 try:
19 from pyreadline import *
20 import pyreadline as _rl
21 have_readline = True
22 except ImportError:
23 have_readline = False
19
24
20 if sys.platform == 'win32' and have_readline:
25 if sys.platform == 'win32' and have_readline:
21 try:
26 try:
22 _outputfile=_rl.GetOutputFile()
27 _outputfile=_rl.GetOutputFile()
23 except NameError:
28 except AttributeError:
24 print "Failed GetOutputFile"
29 print "Failed GetOutputFile"
25 have_readline = False
30 have_readline = False
26
31
27 # the clear_history() function was only introduced in Python 2.4 and is
32 # 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
33 # 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:
34 # existence. Some known platforms actually don't have it. This thread:
30 # http://mail.python.org/pipermail/python-dev/2003-August/037845.html
35 # http://mail.python.org/pipermail/python-dev/2003-August/037845.html
31 # has the original discussion.
36 # has the original discussion.
32
37
33 if have_readline:
38 if have_readline:
34 import readline
35 try:
39 try:
36 readline.clear_history
40 _rl.clear_history
37 except AttributeError:
41 except AttributeError:
38 def clear_history(): pass
42 def clear_history(): pass
39 readline.clear_history = clear_history
43 _rl.clear_history = clear_history No newline at end of file
40 del readline
General Comments 0
You need to be logged in to leave comments. Login now