Skip to content

fix: normalize line endings before parsing pyproject.toml - #26232

Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix-25809-pyproject-crlf-comments
Open

MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix-25809-pyproject-crlf-comments

Conversation

@wasim-builds

Copy link
Copy Markdown

Summary

Fixes #25809

When pyproject.toml uses CRLF line endings (\r\n) on Windows and contains comments (e.g. # comment), @iarna/toml throws an error:
Control characters (codes < 0x1f and 0x7f) are not allowed in comments, use \u000d instead
because it encounters carriage return characters (\r) within comments. This causes tomlParse to fail with Failed to parse pyproject.toml error logs and prevent detection of pip-installable projects and optional dependencies.

Changes

  • In src/client/pythonEnvironments/creation/provider/venvUtils.ts, normalize \r\n and \r line endings to \n in tomlParse before delegating to tomljs.parse.
  • Added unit tests in src/test/pythonEnvironments/creation/provider/venvUtils.unit.test.ts verifying that isPipInstallableToml and pickPackagesToInstall parse pyproject.toml with CRLF line endings and comments without errors.

Verification

  • npx tsc -p ./ succeeded with 0 errors.
  • npx mocha --require out/test/unittests.js out/test/pythonEnvironments/creation/provider/venvUtils.unit.test.js --ui tdd (20 passed).

Copilot AI balanced review requested due to automatic review settings October 17, 2026 12:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to parse pyproject.toml error when pyproject.toml has comments and CRLF line endings

2 participants