KEMBAR78
bug fix: Stricter pip list Package Parsing by sjsikora · Pull Request #698 · microsoft/vscode-python-environments · GitHub
Skip to content

Conversation

sjsikora
Copy link
Contributor

@sjsikora sjsikora commented Aug 7, 2025

Addressing bug #697.

When parsing the output of pip list for packages, two checks were added. First, does the line contain exactly two space-separated keywords? The assumption being we will exactly see "[package name] [package version]" in a valid package list. Secondly, it uses the regex in the PEP 440 docs to verify a valid pip version. Adding these checks will help ensure we only parse valid packages and don't pick up any other information, such as warning messages. Lastly, added a unit test for the situation described in the bug.

@sjsikora
Copy link
Contributor Author

sjsikora commented Aug 7, 2025

@microsoft-github-policy-service agree

@vs-code-engineering vs-code-engineering bot added this to the August 2025 milestone Aug 9, 2025
@karthiknadig karthiknadig added the bug Issue identified by VS Code Team member as probable bug label Aug 9, 2025
@karthiknadig karthiknadig enabled auto-merge (squash) August 9, 2025 04:39
@karthiknadig karthiknadig merged commit 8afb007 into microsoft:main Aug 9, 2025
6 checks passed
eleanorjboyd pushed a commit to eleanorjboyd/vscode-python-environments that referenced this pull request Aug 11, 2025
Addressing bug microsoft#697.

When parsing the output of pip list for packages, two checks were added.
First, does the line contain exactly two space-separated keywords? The
assumption being we will exactly see "[package name] [package version]"
in a valid package list. Secondly, it uses the [regex in the PEP 440
docs](https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions)
to verify a valid pip version. Adding these checks will help ensure we
only parse valid packages and don't pick up any other information, such
as warning messages. Lastly, added a unit test for the situation
described in the bug.
sowhat1989 referenced this pull request in sowhat1989/vscode-python-environments Oct 23, 2025
Addressing bug #697.

When parsing the output of pip list for packages, two checks were added.
First, does the line contain exactly two space-separated keywords? The
assumption being we will exactly see "[package name] [package version]"
in a valid package list. Secondly, it uses the [regex in the PEP 440
docs](https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions)
to verify a valid pip version. Adding these checks will help ensure we
only parse valid packages and don't pick up any other information, such
as warning messages. Lastly, added a unit test for the situation
described in the bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants