##// END OF EJS Templates
Fix bug where bare strings would be silently ignored in input....
Robert Kern -
Show More
@@ -225,6 +225,13 b' def split_blocks(python):'
225 # to put in a more sophisticated test.
225 # to put in a more sophisticated test.
226 linenos = [x.lineno-1 for x in ast.node if x.lineno is not None]
226 linenos = [x.lineno-1 for x in ast.node if x.lineno is not None]
227
227
228 # When we have a bare string as the first statement, it does not end up as
229 # a Discard Node in the AST as we might expect. Instead, it gets interpreted
230 # as the docstring of the module. Check for this case and prepend 0 (the
231 # first line number) to the list of linenos to account for it.
232 if ast.doc is not None:
233 linenos.insert(0, 0)
234
228 # When we finally get the slices, we will need to slice all the way to
235 # When we finally get the slices, we will need to slice all the way to
229 # the end even though we don't have a line number for it. Fortunately,
236 # the end even though we don't have a line number for it. Fortunately,
230 # None does the job nicely.
237 # None does the job nicely.
@@ -347,7 +354,7 b' class InputSplitter(object):'
347 return out
354 return out
348
355
349 def push(self, lines):
356 def push(self, lines):
350 """Push one ore more lines of input.
357 """Push one or more lines of input.
351
358
352 This stores the given lines and returns a status code indicating
359 This stores the given lines and returns a status code indicating
353 whether the code forms a complete Python block or not.
360 whether the code forms a complete Python block or not.
@@ -329,6 +329,15 b' class InputSplitterTestCase(unittest.TestCase):'
329 [['for i in range(10):'
329 [['for i in range(10):'
330 ' x=i**2'],
330 ' x=i**2'],
331 ['z = 1']],
331 ['z = 1']],
332
333 [['"asdf"']],
334
335 [['"asdf"'],
336 ['10'],
337 ],
338
339 [['"""foo',
340 'bar"""']],
332 ]
341 ]
333 for block_lines in all_blocks:
342 for block_lines in all_blocks:
334 self.check_split(block_lines)
343 self.check_split(block_lines)
General Comments 0
You need to be logged in to leave comments. Login now