##// END OF EJS Templates
Catch errors in querying readline which occur with pyreadline.
Thomas Kluyver -
Show More
@@ -144,14 +144,18 b' class ReadlineNoRecord(object):'
144 144
145 145 def __enter__(self):
146 146 if self._nested_level == 0:
147 try:
147 148 self.orig_length = self.current_length()
148 149 self.readline_tail = self.get_readline_tail()
150 except (AttributeError, IndexError): # Can fail with pyreadline
151 self.orig_length, self.readline_tail = 999999, []
149 152 self._nested_level += 1
150 153
151 154 def __exit__(self, type, value, traceback):
152 155 self._nested_level -= 1
153 156 if self._nested_level == 0:
154 157 # Try clipping the end if it's got longer
158 try:
155 159 e = self.current_length() - self.orig_length
156 160 if e > 0:
157 161 for _ in range(e):
@@ -161,6 +165,8 b' class ReadlineNoRecord(object):'
161 165 if self.current_length() != self.orig_length \
162 166 or self.get_readline_tail() != self.readline_tail:
163 167 self.shell.refill_readline_hist()
168 except (AttributeError, IndexError):
169 pass
164 170 # Returning False will cause exceptions to propagate
165 171 return False
166 172
General Comments 0
You need to be logged in to leave comments. Login now