# HG changeset patch # User Paul Boddie # Date 1490055338 -3600 # Node ID 332483cd7ba31863288fcbe8d890b7ce0466dad5 # Parent 77aa11d4aa5afe3f8cada4c1f04d32e57fc76b45 Revert inappropriate optimisations causing the get_using test to produce incorrect output: the context of an arbitrary object must be tested using __get_function even if it is provided by that object. diff -r 77aa11d4aa5a -r 332483cd7ba3 tests/get_using.py --- a/tests/get_using.py Tue Mar 21 00:15:15 2017 +0100 +++ b/tests/get_using.py Tue Mar 21 01:15:38 2017 +0100 @@ -21,6 +21,11 @@ except UnboundMethodInvocation: print "fn(): method is unbound" +try: + print f() # fails +except UnboundMethodInvocation: + print "f(): method is unbound" + d = D() try: fn = get_using(C.f, d) diff -r 77aa11d4aa5a -r 332483cd7ba3 translator.py --- a/translator.py Tue Mar 21 00:15:15 2017 +0100 +++ b/translator.py Tue Mar 21 01:15:38 2017 +0100 @@ -1354,8 +1354,6 @@ if have_access_context: stages.append("__get_function(%s, %s)" % ( context_identity, target_var)) - elif context_var == target_var: - stages.append("__get_function_unchecked(%s)" % target_var) else: stages.append("__get_function(__CONTEXT_AS_VALUE(%s).value, %s)" % ( context_var, target_var)) @@ -1367,10 +1365,7 @@ elif known_parameters: context_arg = context_required and args[0] or "__NULL" if self.always_callable(refs): - if context_var == target_var: - stages.append("__get_function_unchecked(%s)" % target_var) - else: - stages.append("__get_function(%s.value, %s)" % (context_arg, target_var)) + stages.append("__get_function(%s.value, %s)" % (context_arg, target_var)) else: stages.append("__check_and_get_function(%s.value, %s)" % (context_arg, target_var))