Lichen

Changeset

754:332483cd7ba3
2017-03-21 Paul Boddie raw files shortlog changelog graph 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.
tests/get_using.py (file) translator.py (file)
     1.1 --- a/tests/get_using.py	Tue Mar 21 00:15:15 2017 +0100
     1.2 +++ b/tests/get_using.py	Tue Mar 21 01:15:38 2017 +0100
     1.3 @@ -21,6 +21,11 @@
     1.4  except UnboundMethodInvocation:
     1.5      print "fn(): method is unbound"
     1.6  
     1.7 +try:
     1.8 +    print f()                       # fails
     1.9 +except UnboundMethodInvocation:
    1.10 +    print "f(): method is unbound"
    1.11 +
    1.12  d = D()
    1.13  try:
    1.14      fn = get_using(C.f, d)
     2.1 --- a/translator.py	Tue Mar 21 00:15:15 2017 +0100
     2.2 +++ b/translator.py	Tue Mar 21 01:15:38 2017 +0100
     2.3 @@ -1354,8 +1354,6 @@
     2.4                  if have_access_context:
     2.5                      stages.append("__get_function(%s, %s)" % (
     2.6                          context_identity, target_var))
     2.7 -                elif context_var == target_var:
     2.8 -                    stages.append("__get_function_unchecked(%s)" % target_var)
     2.9                  else:
    2.10                      stages.append("__get_function(__CONTEXT_AS_VALUE(%s).value, %s)" % (
    2.11                          context_var, target_var))
    2.12 @@ -1367,10 +1365,7 @@
    2.13          elif known_parameters:
    2.14              context_arg = context_required and args[0] or "__NULL"
    2.15              if self.always_callable(refs):
    2.16 -                if context_var == target_var:
    2.17 -                    stages.append("__get_function_unchecked(%s)" % target_var)
    2.18 -                else:
    2.19 -                    stages.append("__get_function(%s.value, %s)" % (context_arg, target_var))
    2.20 +                stages.append("__get_function(%s.value, %s)" % (context_arg, target_var))
    2.21              else:
    2.22                  stages.append("__check_and_get_function(%s.value, %s)" % (context_arg, target_var))
    2.23