Skip to content

Using break in a loop inside except* gives an error #10766

@McAwesome123

Description

@McAwesome123

Environment data

  • Pylance version: v2025.7.1
  • OS and version: Windows 10 22H2
  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.4

Code Snippet

	except* TimeoutError as exc:
		x = 10
		while True:
			x -= 1
			if x < 0:
				break
			...

Expected behavior

The code works fine as far as I can tell, so this shouldn't be an error.

Actual behavior

Gives "break" is not allowed in an "except*" block

Logs

2025-08-04 00:51:44.664 [info] Native locator: Refresh started
2025-08-04 00:51:44.701 [info] > pyenv which python
2025-08-04 00:51:44.701 [info] cwd: .
2025-08-04 00:51:44.713 [info] Python interpreter path: .\.venv\Scripts\python.exe
2025-08-04 00:51:44.727 [info] Native locator: Refresh finished in 263 ms
2025-08-04 00:51:45.746 [info] Starting Pylance language server.
2025-08-04 00:51:54.855 [info] Discover tests for workspace name: fractalrhomb - uri: d:\GitHub\fractalrhomb\cogs\splash.py
2025-08-04 00:51:59.432 [info] Discover tests for workspace name: fractalrhomb - uri: d:\GitHub\fractalrhomb\cogs\splash.py

Metadata

Metadata

Assignees

Labels

addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions