code: def _python_shell_default(python_shell, __pub_jid):
      '''
      Set python_shell default based on remote execution and __opts__['cmd_safe']
      '''
      try:
          # Default to python_shell=True when run directly from remote execution
          # system. Cross-module calls won't have a jid.
          if __pub_jid and python_shell is None:
              return True
          elif __opts__.get('cmd_safe', True) is False and python_shell is None:
              # Override-switch for python_shell
              return True
      except NameError:
          pass
      return python_shelf _python_shell_default(python_shell, __pub_jid):
      '''
      Set python_shell default based on remote execution and __opts__['cmd_safe']
      '''
      try:
          # Default to python_shell=True when run directly from remote execution
          # system. Cross-module calls won't have a jid.
          if __pub_jid and python_shell is None:
              return True
          elif __opts__.get('cmd_safe', True) is False and python_shell is None:
              # Override-switch for python_shell
              return True
      except NameError:
          pass
      return python_shell
docs: Set python_shell default based on remote execution and __opts__['cmd_safe']