[pypy-commit] pypy online-transforms: change interface of ClassDesc.add_source_attribute()

rlamy noreply at buildbot.pypy.org
Sun Nov 2 23:41:07 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: online-transforms
Changeset: r74328:4539281f65b9
Date: 2014-11-01 15:29 +0000
http://bitbucket.org/pypy/pypy/changeset/4539281f65b9/

Log:	change interface of ClassDesc.add_source_attribute()

diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- a/rpython/annotator/description.py
+++ b/rpython/annotator/description.py
@@ -482,7 +482,8 @@
             if cls not in classdef.FORCE_ATTRIBUTES_INTO_CLASSES:
                 self.all_enforced_attrs = []    # no attribute allowed
 
-    def add_source_attribute(self, name, value, mixin=False):
+    def add_source_attribute(self, cls, name, mixin=False):
+        value = cls.__dict__[name]
         if isinstance(value, types.FunctionType):
             # for debugging
             if not hasattr(value, 'class_'):
@@ -548,14 +549,14 @@
         for base in reversed(mro):
             assert is_mixin(base), (
                 "Mixin class %r has non mixin base class %r" % (mixins, base))
-            for name, value in base.__dict__.items():
+            for name in base.__dict__:
                 if name in skip:
                     continue
-                self.add_source_attribute(name, value, mixin=True)
+                self.add_source_attribute(base, name, mixin=True)
 
     def add_sources_for_class(self, cls):
-        for name, value in cls.__dict__.items():
-            self.add_source_attribute(name, value)
+        for name in cls.__dict__:
+            self.add_source_attribute(cls, name)
 
     def getallclassdefs(self):
         return self._classdefs.values()
@@ -712,7 +713,7 @@
         # check whether there is a new attribute
         cls = self.pyobj
         if name in cls.__dict__:
-            self.add_source_attribute(name, cls.__dict__[name])
+            self.add_source_attribute(cls, name)
             if name in self.classdict:
                 return self
         return None


More information about the pypy-commit mailing list