File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 64
64
65
65
# Prefer statically linked gnureadline if available (for Mac OS X compatibility due to issues with libedit)
66
66
try :
67
- import gnureadline
67
+ import gnureadline as readline
68
68
except ImportError :
69
- import readline
69
+ try :
70
+ import readline
71
+ except ImportError :
72
+ pass
70
73
71
74
# Python 3 compatibility hack due to no built-in file keyword in Python 3
72
75
# Due to one occurrence of isinstance(<foo>, file) checking to see if something is of file type
@@ -1132,9 +1135,12 @@ def _cmdloop(self):
1132
1135
# An almost perfect copy from Cmd; however, the pseudo_raw_input portion
1133
1136
# has been split out so that it can be called separately
1134
1137
if self .use_rawinput and self .completekey :
1135
- self .old_completer = readline .get_completer ()
1136
- readline .set_completer (self .complete )
1137
- readline .parse_and_bind (self .completekey + ": complete" )
1138
+ try :
1139
+ self .old_completer = readline .get_completer ()
1140
+ readline .set_completer (self .complete )
1141
+ readline .parse_and_bind (self .completekey + ": complete" )
1142
+ except NameError :
1143
+ pass
1138
1144
stop = None
1139
1145
try :
1140
1146
while not stop :
@@ -1148,7 +1154,10 @@ def _cmdloop(self):
1148
1154
stop = self .onecmd_plus_hooks (line )
1149
1155
finally :
1150
1156
if self .use_rawinput and self .completekey :
1151
- readline .set_completer (self .old_completer )
1157
+ try :
1158
+ readline .set_completer (self .old_completer )
1159
+ except NameError :
1160
+ pass
1152
1161
return stop
1153
1162
1154
1163
# noinspection PyUnusedLocal
You can’t perform that action at this time.
0 commit comments