Skip to content

Propagate errors raised while consuming to_list inputs - #409

Merged
dgilland merged 2 commits into
dgilland:developfrom
Gambit-Checkmate:fix/to-list-iteration-errors
Nov 2, 2026
Merged

dgilland merged 2 commits into
dgilland:developfrom
Gambit-Checkmate:fix/to-list-iteration-errors

Conversation

@Gambit-Checkmate

@Gambit-Checkmate Gambit-Checkmate commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #408.

Catch TypeError only while obtaining an iterator in to_list's generic fallback, then consume that iterator outside the handler. A generator or legacy sequence that raises TypeError while producing values now propagates the original exception, instead of silently returning a list containing the partially consumed source.

The scalar/non-iterable fallback remains supported, including objects whose __iter__ raises TypeError. Existing list, dict, string and bytes branches are unchanged. Add a documentation clarification and unreleased changelog entry; signatures, dependencies and generated chain files do not change. Existing AUTHORS credit is retained.

Validation

Windows / CPython 3.13.13:

  • Fourteen focused regression/control cases: four fail on pristine develop 785e82b, all fourteen pass after the fix. Direct/chained generator and legacy-sequence cases assert that the original exception instance propagates. Eight non-iterable cases retain identity when wrapped; two length-hint controls agree with Python's builtin list behavior, which ignores TypeError from the optional hint.
  • Full unit/doctest suite: 3,159 passed, 100% coverage.
  • Full configured mypy check, Ruff lint/formatting, Sphinx with warnings as errors, source distribution/wheel builds and git diff --check: passed.
  • Fresh generated chain signatures match the unchanged checked-in stub.

Other Python versions/platforms were not run locally. Hosted Main run 41365825470 is in progress; its result is not yet claimed.

Origin and assistance

Found by source inspection, not a production incident. Checked the open PR inventory and all-state to_list/iteration-error searches, including #107's original scalar-wrapping rationale, before reporting the distinct failure-handling problem.

OpenAI Codex (GPT-6 family; exact deployment identifier unavailable) assisted with investigation, implementation and verification. The user requested independently useful, tested contributions and avoidance of duplicate work; no independent human review is claimed.

@coveralls

coveralls commented Nov 2, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — Gambit-Checkmate:fix/to-list-iteration-errors into dgilland:develop

@dgilland
dgilland merged commit 5ae4792 into dgilland:develop Nov 2, 2026
5 checks passed
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.

to_list swallows TypeError raised while consuming iterable values

3 participants