Skip to content

Preserve dictionary errors in case-insensitive mappings - #96

Open
ShahadatTest wants to merge 2 commits into
xolox:masterfrom
ShahadatTest:fix/case-insensitive-dict-errors
Open

ShahadatTest wants to merge 2 commits into
xolox:masterfrom
ShahadatTest:fix/case-insensitive-dict-errors

Conversation

@ShahadatTest

@ShahadatTest ShahadatTest commented Oct 27, 2026 •

Copy link
Copy Markdown

CaseInsensitiveDict.pop currently supplies an implicit None default, so removing a missing key silently succeeds. update(42) raises UnboundLocalError while trying to build its intended TypeError message. Distinguish an omitted pop default with a private sentinel, preserving explicit defaults passed positionally or with default=, and use the actual source object when reporting unsupported updates.

Both regressions fail before the fix. Explicit None/object defaults and existing differently-cased keys are covered. On Windows/Python 3.12 the full suite reports 65 passed, 6 failed, compared with 63 passed, the same 6 failed on unmodified master. These existing failures concern CLI subprocesses, HOME/path handling, warning hooks and terminal mocks. All 4 case-insensitive tests pass on Python 3.10. Configured Flake8 (including docstrings) and diff checks pass. Other supported runtimes were not run.

Prepared with OpenAI Codex (GPT-6) assistance for new 20ta koro (make 20 new contributions). Investigation, implementation and tests were AI-assisted; no personal production use or human code review is claimed.

marco8154 added a commit to marco8154/python-humanfriendly-ng that referenced this pull request Nov 25, 2026
CaseInsensitiveDict.update(42) raised UnboundLocalError instead of the
intended TypeError, because the error message used an unbound variable.

Taken from xolox#96 without its change to pop(), which
would make pop() of a missing key raise KeyError instead of returning None.

Co-authored-by: Shahadat Islam Koyel <179203101+ShahadatTest@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant