<div dir="ltr">Alright, I'll revert this loop for now. This is in at r255567.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 14, 2015 at 2:33 PM Siva Chandra <<a href="mailto:sivachandra@google.com">sivachandra@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Dec 14, 2015 at 2:15 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> Diff looks like this:<br>
><br>
> - @dwarf_test<br>
> - @wraps(attrvalue)<br>
> - def dwarf_test_method(self, attrvalue=attrvalue):<br>
> - self.debug_info = "dwarf"<br>
> - return attrvalue(self)<br>
> - dwarf_method_name = attrname + "_dwarf"<br>
> - dwarf_test_method.__name__ = dwarf_method_name<br>
> - newattrs[dwarf_method_name] = dwarf_test_method<br>
><br>
> ...<br>
><br>
> + for category in supported_categories:<br>
> + @add_test_categories([category])<br>
> + @wraps(attrvalue)<br>
> + def test_method(self, attrvalue=attrvalue):<br>
> + self.debug_info = category<br>
> + return attrvalue(self)<br>
> + method_name = attrname + "_" + category<br>
> + test_method.__name__ = method_name<br>
> + newattrs[method_name] = test_method<br>
><br>
><br>
> So it looks like it's still under a different function. The difference is<br>
> that before (in the - section of the diff) there were 3 different functions<br>
> with 3 different names. For example `dwarf_test_method` above. In the new<br>
> code (+ section of the diff) it looks like one function defined 3 different<br>
> times with the same name `test_method`. But each of these should be a<br>
> distinct function object that is defined in the context of the closure<br>
> determined by the enclosing scope (the for loop in this case). So all 3<br>
> functions are actually different. self is just an argument to the function,<br>
> not some magic value like `this` in C++, so as in the previous version, the<br>
> `debug_info` that gets modified is on whatever instance of `self` gets<br>
> passed into the function, same as before.<br>
<br>
I think you are right. I am only basing my theories by feeling the<br>
elephant blind here. When running TestWithLimitDebugInfo, I have<br>
printed the |category| value from test_method and it only prints<br>
"dwo". So, it is |category| which is at fault here as it is the loop<br>
variable. Though two different methods are actually getting added,<br>
self.debug_info refers to the last value of |category|.<br>
<br>
> Tamas or Pavel can probably clarify, but that's my understanding.<br>
</blockquote></div>