@@ -107,7 +107,9 @@ def run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_pyth
107107 # blow away the discovered_interpreter_config cache and rediscover
108108 del task_vars ['ansible_facts' ][discovered_interpreter_config ]
109109
110- if discovered_interpreter_config not in task_vars ['ansible_facts' ]:
110+ try :
111+ s = task_vars ['ansible_facts' ][discovered_interpreter_config ]
112+ except KeyError :
111113 action ._mitogen_discovering_interpreter = True
112114 # fake pipelining so discover_interpreter can be happy
113115 action ._connection .has_pipelining = True
@@ -121,8 +123,6 @@ def run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_pyth
121123 # cache discovered interpreter
122124 task_vars ['ansible_facts' ][discovered_interpreter_config ] = s
123125 action ._connection .has_pipelining = False
124- else :
125- s = task_vars ['ansible_facts' ][discovered_interpreter_config ]
126126
127127 # propagate discovered interpreter as fact
128128 action ._discovered_interpreter_key = discovered_interpreter_config
@@ -144,9 +144,8 @@ def parse_python_path(s, task_vars, action, rediscover_python):
144144 s = 'auto'
145145
146146 s = run_interpreter_discovery_if_necessary (s , task_vars , action , rediscover_python )
147- # if unable to determine python_path, fallback to '/usr/bin/python'
148147 if not s :
149- s = '/usr/bin/python'
148+ raise ValueError ( "Interpreter discovery failed, got: %r" , s )
150149
151150 return ansible .utils .shlex .shlex_split (s )
152151
0 commit comments