@@ -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
@@ -140,13 +140,11 @@ def parse_python_path(s, task_vars, action, rediscover_python):
140140 discovery value in `facts_from_task_vars` like how Ansible handles this.
141141 """
142142 if not s :
143- # if python_path doesn't exist, default to `auto` and attempt to discover it
144- s = 'auto'
143+ raise ValueError ("Expected Python path or discovery mode, got: %r" , s )
145144
146145 s = run_interpreter_discovery_if_necessary (s , task_vars , action , rediscover_python )
147- # if unable to determine python_path, fallback to '/usr/bin/python'
148146 if not s :
149- s = '/usr/bin/python'
147+ raise ValueError ( "Interpreter discovery failed, got: %r" , s )
150148
151149 return ansible .utils .shlex .shlex_split (s )
152150
0 commit comments