Source

rope_py3k / rope / base / pyobjectsdef.py

Diff from to

File rope/base/pyobjectsdef.py

 
     def get_param_names(self, special_args=True):
         # TODO: handle tuple parameters
-        result = [node.id for node in self.arguments.args
-                  if isinstance(node, ast.Name)]
+        result = [node.arg for node in self.arguments.args
+                  if isinstance(node, ast.arg)]
         if special_args:
             if self.arguments.vararg:
                 result.append(self.arguments.vararg)
                 source_bytes = resource.read_bytes()
                 source_code = fscommands.file_data_to_unicode(source_bytes)
             else:
-                if isinstance(source_code, unicode):
+                if isinstance(source_code, str):
                     source_bytes = fscommands.unicode_to_file_data(source_code)
                 else:
                     source_bytes = source_code
             ast_node = ast.parse(source_bytes, filename=filename)
-        except SyntaxError, e:
+        except SyntaxError as e:
             raise exceptions.ModuleSyntaxError(filename, e.lineno, e.msg)
-        except UnicodeDecodeError, e:
+        except UnicodeDecodeError as e:
             raise exceptions.ModuleSyntaxError(filename, 1, '%s' % (e.reason))
         return source_code, ast_node
 
         result = {}
         modname = self.pycore.modname(self.resource)
         extension_submodules = self.pycore._builtin_submodules(modname)
-        for name, module in extension_submodules.iteritems():
+        for name, module in extension_submodules.items():
             result[name] = rope.base.builtins.BuiltinName(module)
         if self.resource is None:
             return result
     def _update_evaluated(self, targets, assigned,
                           evaluation= '', eval_type=False):
         result = {}
-        names = astutils.get_name_levels(targets)
-        for name, levels in names:
-            assignment = pynames.AssignmentValue(assigned, levels,
+        if not isinstance(targets, str):
+            names = astutils.get_name_levels(targets)
+            for name, levels in names:
+                assignment = pynames.AssignmentValue(assigned, levels,
+                                                     evaluation, eval_type)
+                self._assigned(name, assignment)
+        else:
+            assignment = pynames.AssignmentValue(assigned, [],
                                                  evaluation, eval_type)
-            self._assigned(name, assignment)
+            self._assigned(targets, assignment)
         return result
 
     def _With(self, node):
             ast.walk(child, self)
 
     def _excepthandler(self, node):
-        if node.name is not None and isinstance(node.name, ast.Name):
+        if node.name is not None and isinstance(node.name, str):
             type_node = node.type
             if isinstance(node.type, ast.Tuple) and type_node.elts:
                 type_node = type_node.elts[0]
         _ScopeVisitor._FunctionDef(self, node)
         if len(node.args.args) > 0:
             first = node.args.args[0]
-            if isinstance(first, ast.Name):
-                new_visitor = _ClassInitVisitor(self, first.id)
+            if isinstance(first, ast.arg):
+                new_visitor = _ClassInitVisitor(self, first.arg)
                 for child in ast.get_child_nodes(node):
                     ast.walk(child, new_visitor)