1.1 --- a/deducer.py Fri Sep 30 15:26:59 2016 +0200
1.2 +++ b/deducer.py Fri Sep 30 17:40:53 2016 +0200
1.3 @@ -1768,6 +1768,11 @@
1.4 provided_by_class = "<class>" in provider_kinds
1.5 provided_by_instance = "<instance>" in provider_kinds
1.6
1.7 + # Determine how attributes may be accessed relative to the accessor.
1.8 +
1.9 + object_relative = class_accessor or module_accessor or provided_by_instance
1.10 + class_relative = instance_accessor and provided_by_class
1.11 +
1.12 # Identify the last static attribute for context acquisition.
1.13
1.14 base = None
1.15 @@ -1849,7 +1854,7 @@
1.16
1.17 # Identified attribute that must be accessed via its parent.
1.18
1.19 - if attr and attr.get_name() and (not attr.static() or location in self.reference_assignments):
1.20 + if attr and attr.get_name() and location in self.reference_assignments:
1.21 method = "direct"; origin = attr.get_name()
1.22
1.23 # Static, identified attribute.
1.24 @@ -1860,17 +1865,15 @@
1.25 # Attribute accessed at a known position via its parent.
1.26
1.27 elif base or dynamic_base:
1.28 - method = "relative"; origin = None
1.29 + method = "relative" + (object_relative and "-object" or "") + \
1.30 + (class_relative and "-class" or "")
1.31 + origin = None
1.32
1.33 # The fallback case is always run-time testing and access.
1.34
1.35 else:
1.36 - l = []
1.37 - if class_accessor or module_accessor or provided_by_instance:
1.38 - l.append("checkobject")
1.39 - if instance_accessor and provided_by_class:
1.40 - l.append("checkclass")
1.41 - method = "+".join(l)
1.42 + method = "check" + (object_relative and "-object" or "") + \
1.43 + (class_relative and "-class" or "")
1.44 origin = None
1.45
1.46 return base or name, traversed, attrnames, method, test, origin
2.1 --- a/tests/chain.py Fri Sep 30 15:26:59 2016 +0200
2.2 +++ b/tests/chain.py Fri Sep 30 17:40:53 2016 +0200
2.3 @@ -8,9 +8,17 @@
2.4 return self.o.__len__
2.5 n = 123
2.6 o = "123"
2.7 +
2.8 p = "456"
2.9 q = 789
2.10
2.11 + class F(E):
2.12 + def r(self, y):
2.13 + s = self.o
2.14 + C.D.F.t = 234
2.15 + return self.o.__len__
2.16 + t = 123
2.17 +
2.18 def main():
2.19 c = C
2.20 d = C.D