From b8c4218e8fcacaa51fdc2a6cba22bfb0d872c856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Szramowski?= Date: Tue, 21 Dec 2021 22:25:15 +0100 Subject: [PATCH] Explain why using subprocess.list2cmdline is a bad idea --- news/eb0afbc2-59df-40a3-b7bd-325305c3e2e7.trivial.rst | 0 src/pip/_internal/self_outdated_check.py | 6 +++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 news/eb0afbc2-59df-40a3-b7bd-325305c3e2e7.trivial.rst diff --git a/news/eb0afbc2-59df-40a3-b7bd-325305c3e2e7.trivial.rst b/news/eb0afbc2-59df-40a3-b7bd-325305c3e2e7.trivial.rst new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/pip/_internal/self_outdated_check.py b/src/pip/_internal/self_outdated_check.py index 72f70fc2597..19a5f280f60 100644 --- a/src/pip/_internal/self_outdated_check.py +++ b/src/pip/_internal/self_outdated_check.py @@ -165,7 +165,11 @@ def pip_self_version_check(session: PipSession, options: optparse.Values) -> Non # We cannot tell how the current pip is available in the current # command context, so be pragmatic here and suggest the command # that's always available. This does not accommodate spaces in - # `sys.executable`. + # `sys.executable` on purpose as it is not possible to do it + # correctly without knowing the user's shell. Thus, + # it won't be done until possible through the standard library. + # Do not be tempted to use the undocumented subprocess.list2cmdline. + # It is considered an internal implementation detail for a reason. pip_cmd = f"{sys.executable} -m pip" logger.warning( "You are using pip version %s; however, version %s is "