summaryrefslogtreecommitdiffstats
path: root/Lib/ensurepip
diff options
context:
space:
mode:
authorCarter Dodd <carter.dodd@gmail.com>2022-07-05 15:23:44 (GMT)
committerGitHub <noreply@github.com>2022-07-05 15:23:44 (GMT)
commitc8556bcf6c0b05ac46bd74880626a2853e7c99a1 (patch)
tree95d8914c67931c8c8228b27318cd13aa0dd0be75 /Lib/ensurepip
parent067597522a9002f3b8aff7f46033f10acb2381e4 (diff)
downloadcpython-c8556bcf6c0b05ac46bd74880626a2853e7c99a1.zip
cpython-c8556bcf6c0b05ac46bd74880626a2853e7c99a1.tar.gz
cpython-c8556bcf6c0b05ac46bd74880626a2853e7c99a1.tar.bz2
gh-90355: Add isolated flag if currently isolated (GH-92857)
Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/ensurepip')
-rw-r--r--Lib/ensurepip/__init__.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
index a198a86..1f25825 100644
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -89,8 +89,18 @@ sys.path = {additional_paths or []} + sys.path
sys.argv[1:] = {args}
runpy.run_module("pip", run_name="__main__", alter_sys=True)
"""
- return subprocess.run([sys.executable, '-W', 'ignore::DeprecationWarning',
- "-c", code], check=True).returncode
+
+ cmd = [
+ sys.executable,
+ '-W',
+ 'ignore::DeprecationWarning',
+ '-c',
+ code,
+ ]
+ if sys.flags.isolated:
+ # run code in isolated mode if currently running isolated
+ cmd.insert(1, '-I')
+ return subprocess.run(cmd, check=True).returncode
def version():