##// END OF EJS Templates
Stop-gap fix for crash with unicode input....
Fernando Perez -
Show More
@@ -958,6 +958,10 b' class IPythonInputSplitter(InputSplitter):'
958 if not lines:
958 if not lines:
959 return super(IPythonInputSplitter, self).push(lines)
959 return super(IPythonInputSplitter, self).push(lines)
960
960
961 # We must ensure all input is pure unicode
962 if type(lines)==str:
963 lines = lines.decode(self.encoding)
964
961 lines_list = lines.splitlines()
965 lines_list = lines.splitlines()
962
966
963 transforms = [transform_escaped, transform_assign_system,
967 transforms = [transform_escaped, transform_assign_system,
@@ -2256,10 +2256,18 b' class InteractiveShell(Configurable, Magic):'
2256
2256
2257 # We need to ensure that the source is unicode from here on.
2257 # We need to ensure that the source is unicode from here on.
2258 if type(source)==str:
2258 if type(source)==str:
2259 source = source.decode(self.stdin_encoding)
2259 usource = source.decode(self.stdin_encoding)
2260 else:
2261 usource = source
2262
2263 if 0: # dbg
2264 print 'Source:', repr(source) # dbg
2265 print 'USource:', repr(usource) # dbg
2266 print 'type:', type(source) # dbg
2267 print 'encoding', self.stdin_encoding # dbg
2260
2268
2261 try:
2269 try:
2262 code = self.compile(source,filename,symbol)
2270 code = self.compile(usource,filename,symbol)
2263 except (OverflowError, SyntaxError, ValueError, TypeError, MemoryError):
2271 except (OverflowError, SyntaxError, ValueError, TypeError, MemoryError):
2264 # Case 1
2272 # Case 1
2265 self.showsyntaxerror(filename)
2273 self.showsyntaxerror(filename)
@@ -347,6 +347,10 b' class InputSplitterTestCase(unittest.TestCase):'
347 for block_lines in all_blocks:
347 for block_lines in all_blocks:
348 self.check_split(block_lines, compile=False)
348 self.check_split(block_lines, compile=False)
349
349
350 def test_unicode(self):
351 self.isp.push(u"Pérez")
352 self.isp.push(u'\xc3\xa9')
353 self.isp.push("u'\xc3\xa9'")
350
354
351 class InteractiveLoopTestCase(unittest.TestCase):
355 class InteractiveLoopTestCase(unittest.TestCase):
352 """Tests for an interactive loop like a python shell.
356 """Tests for an interactive loop like a python shell.
General Comments 0
You need to be logged in to leave comments. Login now