Commits

a...@lilem  committed 4dde54b

patchedast: handle ExtSlice node

Reported-by: Mathew Yeates <myeates@jpl.nasa.gov>

  • Participants
  • Parent commits eeb31f8

Comments (0)

Files changed (2)

File rope/refactor/patchedast.py

             children.extend([',', node.locals])
         self._handle(node, children)
 
+    def _ExtSlice(self, node):
+        children = []
+        for index, dim in enumerate(node.dims):
+            if index > 0:
+                children.append(',')
+            children.append(dim)
+        self._handle(node, children)
+
     def _For(self, node):
         children = ['for', node.target, 'in', node.iter, ':']
         children.extend(node.body)

File ropetest/refactor/patchedasttest.py

             'comprehension', ['for', ' ', 'Name', ' ', 'in', ' ',
                               'Call', ' ', 'if', ' ', 'Name'])
 
+    def test_ext_slice_node(self):
+        source = 'x = xs[0,:]\n'
+        ast = patchedast.get_patched_ast(source, True)
+        checker = _ResultChecker(self, ast)
+        checker.check_region('ExtSlice', 7, len(source) - 2)
+        checker.check_children('ExtSlice', ['Index', '', ',', '', 'Slice'])
+
     def test_simple_module_node(self):
         source = 'pass\n'
         ast = patchedast.get_patched_ast(source, True)