##// END OF EJS Templates
fixed rlineimpl to work properly with py2exed pyreadline
vivainio -
Show More
@@ -1,40 +1,43 b''
1 1 # -*- coding: utf-8 -*-
2 2 """ Imports and provides the 'correct' version of readline for the platform.
3 3
4 4 Readline is used throughout IPython as 'import IPython.rlineimpl as readline'.
5 5
6 6 In addition to normal readline stuff, this module provides have_readline
7 7 boolean and _outputfile variable used in genutils.
8 8
9 9 $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $"""
10 10
11 11 import sys
12 12
13 13 try:
14 14 from readline import *
15 15 import readline as _rl
16 16 have_readline = True
17 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 25 if sys.platform == 'win32' and have_readline:
21 26 try:
22 27 _outputfile=_rl.GetOutputFile()
23 except NameError:
28 except AttributeError:
24 29 print "Failed GetOutputFile"
25 30 have_readline = False
26 31
27 32 # the clear_history() function was only introduced in Python 2.4 and is
28 33 # actually optional in the readline API, so we must explicitly check for its
29 34 # existence. Some known platforms actually don't have it. This thread:
30 35 # http://mail.python.org/pipermail/python-dev/2003-August/037845.html
31 36 # has the original discussion.
32 37
33 38 if have_readline:
34 import readline
35 39 try:
36 readline.clear_history
40 _rl.clear_history
37 41 except AttributeError:
38 42 def clear_history(): pass
39 readline.clear_history = clear_history
40 del readline
43 _rl.clear_history = clear_history No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now