mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
bpo-43218: Prevent venv creation when the target directory contains a PATH separator. (GH-24530)
This commit is contained in:
parent
15537c51c1
commit
54f67ad543
3 changed files with 13 additions and 0 deletions
|
|
@ -467,6 +467,14 @@ class BasicTest(BaseTest):
|
|||
'import os; print("__PYVENV_LAUNCHER__" in os.environ)'])
|
||||
self.assertEqual(out.strip(), 'False'.encode())
|
||||
|
||||
def test_pathsep_error(self):
|
||||
"""
|
||||
Test that venv creation fails when the target directory contains
|
||||
the path separator.
|
||||
"""
|
||||
rmtree(self.env_dir)
|
||||
self.assertRaises(ValueError, venv.create, self.env_dir + os.pathsep)
|
||||
|
||||
@requireVenvCreate
|
||||
class EnsurePipTest(BaseTest):
|
||||
"""Test venv module installation of pip."""
|
||||
|
|
|
|||
|
|
@ -116,6 +116,9 @@ class EnvBuilder:
|
|||
elif os.path.islink(d) or os.path.isfile(d):
|
||||
raise ValueError('Unable to create directory %r' % d)
|
||||
|
||||
if os.pathsep in env_dir:
|
||||
raise ValueError(f'Refusing to create a venv in {env_dir} because '
|
||||
f'it contains the PATH separator {os.pathsep}.')
|
||||
if os.path.exists(env_dir) and self.clear:
|
||||
self.clear_directory(env_dir)
|
||||
context = types.SimpleNamespace()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
Prevent creation of a venv whose path contains the PATH separator. This
|
||||
could affect the usage of the activate script. Patch by Dustin Rodrigues.
|
||||
Loading…
Add table
Add a link
Reference in a new issue