Skip to content

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

@joelspadin

Description

@joelspadin

Environment data

  • Pylance version: 2026.1.1
  • OS and version: Windows 11 build 26200
  • Python version (& distribution if applicable, e.g. Anaconda): 3.14.2

Code Snippet

[tool.ruff.lint]
select = [
  # flake8-builtins
  "A"
]

Repro Steps

Create a pyproject.toml, set line endings to CRLF, then simply add a comment anywhere. The Python logs in the output panel will then log an error like this:

2026-02-21 16:17:12.732 [error] Failed to parse `pyproject.toml`: [TomlError: Control characters (codes < 0x1f and 0x7f) are not allowed in comments, use \u000d instead at row 28, col 20, pos 620:
27: select = [
28>   # flake8-builtins
                       ^
29:   "A",


	at i.errorControlCharIn (c:\Users\Joel\.vscode\extensions\ms-python.python-2026.2.0-win32-x64\out\client\extension.js:2:1109372)
	at i.parseComment (c:\Users\Joel\.vscode\extensions\ms-python.python-2026.2.0-win32-x64\out\client\extension.js:2:1101920)
	at i.runOne (c:\Users\Joel\.vscode\extensions\ms-python.python-2026.2.0-win32-x64\out\client\extension.js:2:1093896)
	at i.parse (c:\Users\Joel\.vscode\extensions\ms-python.python-2026.2.0-win32-x64\out\client\extension.js:2:1093642)
	at e.exports (c:\Users\Joel\.vscode\extensions\ms-python.python-2026.2.0-win32-x64\out\client\extension.js:2:1127199)
	at E (c:\Users\Joel\.vscode\extensions\ms-python.python-2026.2.0-win32-x64\out\client\extension.js:2:802534)
	at t.isPipInstallableToml (c:\Users\Joel\.vscode\extensions\ms-python.python-2026.2.0-win32-x64\out\client\extension.js:2:802782)
	at s (c:\Users\Joel\.vscode\extensions\ms-python.python-2026.2.0-win32-x64\out\client\extension.js:2:806995)
	at c:\Users\Joel\.vscode\extensions\ms-python.python-2026.2.0-win32-x64\out\client\extension.js:2:807364
	at ef.value (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:213:103000)
	at I.C (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:2328)
	at I.D (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:2398)
	at I.fire (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:2615)
	at JZ.$acceptModelSaved (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:144:125565)
	at LE.S (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:125501)
	at LE.Q (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:125281)
	at LE.M (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:124370)
	at LE.L (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:123475)
	at ef.value (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:122272)
	at I.C (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:2328)
	at I.fire (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:2546)
	at Jo.fire (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:9471)
	at ef.value (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:405:9337)
	at I.C (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:2328)
	at I.fire (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:2546)
	at Jo.fire (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:9471)
	at MessagePortMain.<anonymous> (file:///c:/Users/Joel/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:405:7571)
	at MessagePortMain.emit (node:events:519:28)
	at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:2959)] {
  fromTOML: true,
  wrapped: null,
  line: 27,
  col: 19,
  pos: 620
}

Switching the line ending to LF prevents this error from showing in the logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions