diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 9208a4c9134..b6104396ded 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1900,18 +1900,18 @@ class AnsibleModule(object): the execution to hang (especially if no input data is specified) :kw environ_update: dictionary to *update* environ variables with :kw umask: Umask to be used when running the command. Default None - :kw encoding: Since we return native strings, on python3 we need to + :kw encoding: Since we return strings, we need to know the encoding to use to transform from bytes to text. If you want to always get bytes back, use encoding=None. The default is "utf-8". This does not affect transformation of strings given as args. - :kw errors: Since we return native strings, on python3 we need to + :kw errors: Since we return strings, we need to transform stdout and stderr from bytes to text. If the bytes are undecodable in the ``encoding`` specified, then use this error handler to deal with them. The default is ``surrogate_or_strict`` which means that the bytes will be decoded using the surrogateescape error handler if available (available on all - python3 versions we support) otherwise a UnicodeError traceback + Python versions we support) otherwise a UnicodeError traceback will be raised. This does not affect transformations of strings given as args. :kw expand_user_and_vars: When ``use_unsafe_shell=False`` this argument @@ -1919,10 +1919,8 @@ class AnsibleModule(object): are expanded before running the command. When ``True`` a string such as ``$SHELL`` will be expanded regardless of escaping. When ``False`` and ``use_unsafe_shell=False`` no path or variable expansion will be done. - :kw pass_fds: When running on Python 3 this argument - dictates which file descriptors should be passed - to an underlying ``Popen`` constructor. On Python 2, this will - set ``close_fds`` to False. + :kw pass_fds: This argument dictates which file descriptors should be passed + to an underlying ``Popen`` constructor. :kw before_communicate_callback: This function will be called after ``Popen`` object will be created but before communicating to the process. @@ -1933,11 +1931,10 @@ class AnsibleModule(object): :kw handle_exceptions: This flag indicates whether an exception will be handled inline and issue a failed_json or if the caller should handle it. - :returns: A 3-tuple of return code (integer), stdout (native string), - and stderr (native string). On python2, stdout and stderr are both - byte strings. On python3, stdout and stderr are text strings converted - according to the encoding and errors parameters. If you want byte - strings on python3, use encoding=None to turn decoding to text off. + :returns: A 3-tuple of return code (int), stdout (str), and stderr (str). + stdout and stderr are text strings converted according to the encoding + and errors parameters. If you want byte strings, use encoding=None + to turn decoding to text off. """ # used by clean args later on self._clean = None diff --git a/lib/ansible/modules/pip.py b/lib/ansible/modules/pip.py index 39e3457696a..20e6249b759 100644 --- a/lib/ansible/modules/pip.py +++ b/lib/ansible/modules/pip.py @@ -60,7 +60,7 @@ options: virtualenv_python: description: - The Python executable used for creating the virtual environment. - For example V(python3.12), V(python2.7). When not specified, the + For example V(python3.13). When not specified, the Python version used to run the ansible module is used. This parameter should not be used when O(virtualenv_command) is using V(pyvenv) or the C(-m venv) module. @@ -93,8 +93,8 @@ options: description: - The explicit executable or pathname for the C(pip) executable, if different from the Ansible Python interpreter. For - example V(pip3.3), if there are both Python 2.7 and 3.3 installations - in the system and you want to run pip for the Python 3.3 installation. + example V(pip3.13), if there are multiple Python installations + in the system and you want to run pip for the Python 3.13 installation. - Mutually exclusive with O(virtualenv) (added in 2.1). - Does not affect the Ansible Python interpreter. - The C(setuptools) package must be installed for both the Ansible Python interpreter @@ -134,7 +134,7 @@ notes: the virtualenv needs to be created. - Although it executes using the Ansible Python interpreter, the pip module shells out to run the actual pip command, so it can use any pip version you specify with O(executable). - By default, it uses the pip version for the Ansible Python interpreter. For example, pip3 on python 3, and pip2 or pip on python 2. + By default, it uses the pip version for the Ansible Python interpreter. - The interpreter used by Ansible (see R(ansible_python_interpreter, ansible_python_interpreter)) requires the setuptools package, regardless of the version of pip set with @@ -197,11 +197,11 @@ EXAMPLES = """ virtualenv: /my_app/venv virtualenv_site_packages: yes -- name: Install bottle into the specified (virtualenv), using Python 2.7 +- name: Install bottle into the specified (virtualenv), using Python 3.13 ansible.builtin.pip: name: bottle virtualenv: /my_app/venv - virtualenv_command: virtualenv-2.7 + virtualenv_command: virtualenv-3.13 - name: Install bottle within a user home directory ansible.builtin.pip: @@ -227,10 +227,10 @@ EXAMPLES = """ requirements: /my_app/requirements.txt extra_args: "--no-index --find-links=file:///my_downloaded_packages_dir" -- name: Install bottle for Python 3.3 specifically, using the 'pip3.3' executable +- name: Install bottle for Python 3.13 specifically, using the 'pip3.13' executable ansible.builtin.pip: name: bottle - executable: pip3.3 + executable: pip3.13 - name: Install bottle, forcing reinstallation if it's already installed ansible.builtin.pip: @@ -460,9 +460,7 @@ def _get_pip(module, env=None, executable=None): candidate_pip_basenames = (executable,) elif executable is None and env is None and _have_pip_module(): # If no executable or virtualenv were specified, use the pip module for the current Python interpreter if available. - # Use of `__main__` is required to support Python 2.6 since support for executing packages with `runpy` was added in Python 2.7. - # Without it Python 2.6 gives the following error: pip is a package and cannot be directly executed - pip = [sys.executable, '-m', 'pip.__main__'] + pip = [sys.executable, '-m', 'pip'] if pip is None: if env is None: diff --git a/lib/ansible/modules/raw.py b/lib/ansible/modules/raw.py index 5825a465023..e926f027c51 100644 --- a/lib/ansible/modules/raw.py +++ b/lib/ansible/modules/raw.py @@ -73,8 +73,8 @@ author: """ EXAMPLES = r""" -- name: Bootstrap a host without python2 installed - ansible.builtin.raw: dnf install -y python2 python2-dnf libselinux-python +- name: Bootstrap a host without Python installed + ansible.builtin.raw: dnf install -y python3 python3-libdnf - name: Run a command that uses non-posix shell-isms (in this example /bin/sh doesn't handle redirection and wildcards together but bash does) ansible.builtin.raw: cat < /tmp/*txt