Source

rope_py3k / rope / refactor / patchedast.py

Diff from to

rope/refactor/patchedast.py

             if child is None:
                 continue
             offset = self.source.offset
-            if isinstance(child, ast.AST):
+            if isinstance(child, ast.arg):
+                region = self.source.consume(child.arg)
+                child = self.source[region[0]:region[1]]
+                token_start = offset
+            elif isinstance(child, ast.AST):
                 ast.call_for_nodes(child, self)
                 token_start = child.region[0]
             else:
         start = 0
         opens = 0
         for child in children:
-            if not isinstance(child, basestring):
+            if not isinstance(child, str):
                 continue
             if child == '' or child[0] in '\'"':
                 continue
         children = []
         children.append('{')
         if node.keys:
-            for index, (key, value) in enumerate(zip(node.keys, node.values)):
+            for index, (key, value) in enumerate(list(zip(node.keys, node.values))):
                 children.extend([key, ':', value])
                 if index < len(node.keys) - 1:
                     children.append(',')
         children = []
         args = list(node.args)
         defaults = [None] * (len(args) - len(node.defaults)) + list(node.defaults)
-        for index, (arg, default) in enumerate(zip(args, defaults)):
+        for index, (arg, default) in enumerate(list(zip(args, defaults))):
             if index > 0:
                 children.append(',')
             self._add_args_to_children(children, arg, default)
         if node.type:
             children.append(node.type)
         if node.name:
-            children.extend([',', node.name])
+            children.extend(['as', node.name])
         children.append(':')
         children.extend(node.body)
         self._handle(node, children)