[New-bugs-announce] [issue44388] venv API Docs for EnvBuilder.ensure_directories incorrectly describe behavior

Matthew Clapp report at bugs.python.org
Fri Jun 11 01:00:48 EDT 2021


New submission from Matthew Clapp <itsayellow+dev at gmail.com>:

The docs for the venv module, EnvBuilder class, ensure_directories method, describe behavior that doesn't match what its actual behavior is, (and what the code is).  I propose to update the documentation of the API to match the actual behavior.

https://docs.python.org/3.9/library/venv.html#venv.EnvBuilder.ensure_directories

The last sentence for ensure_directories(env_dir) reads:
The directories are allowed to exist already, as long as either clear or upgrade were specified to allow operating on an existing environment directory.

After testing and looking at the code (including past commits back over 6 years), this is not true.  ensure_directories completely disregards the `upgrade` attribute.  Also it allows directories to exist already unconditionally (always operating without error), whether the `clear` attribute is set or not.  In addition, if `clear` is not set, it doesn't make any changes to the directories, but helpfully still returns the context of venv paths.

Ref: https://github.com/python/cpython/blob/3ce35bfbbe29664942f9a8c50c177a4575a31934/Lib/venv/__init__.py#L95

----------
assignee: docs at python
components: Documentation
messages: 395603
nosy: docs at python, itsayellow
priority: normal
severity: normal
status: open
title: venv API Docs for EnvBuilder.ensure_directories incorrectly describe behavior
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44388>
_______________________________________


More information about the New-bugs-announce mailing list