diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/venv/__init__.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py index 8d2deb7..3553fec 100644 --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -105,7 +105,15 @@ class EnvBuilder: if os.path.exists(env_dir) and not (self.clear or self.upgrade): raise ValueError('Directory exists: %s' % env_dir) if os.path.exists(env_dir) and self.clear: - shutil.rmtree(env_dir) + # Issue 15776: To support running pyvenv on '.', the venv + # directory contents are emptied and recreated, instead of + # the venv directory being deleted and recreated. + for f in os.listdir(env_dir): + f = os.path.join(env_dir, f) + if os.path.isdir(f): + shutil.rmtree(f) + else: + os.remove(f) context = Context() context.env_dir = env_dir context.env_name = os.path.split(env_dir)[1] |