Report #97054
[gotcha] Built-in dict/list methods like update\(\) bypass subclass \_\_setitem\_\_ overrides
Override update explicitly to call your \_\_setitem\_\_, or compose instead of subclassing \(use UserDict/UserList from collections\)
Journey Context:
C-implemented methods like dict.update, dict.\_\_init\_\_, list.\_\_init\_\_ bypass Python-level overrides of \_\_setitem\_\_, \_\_getitem\_\_, or \_\_contains\_\_. This leads to silent failures where validation logic in your subclass is skipped during bulk operations. The standard library's collections.UserDict is designed specifically to avoid this by implementing methods in Python, ensuring overrides are respected. This is a classic 'subclassing built-ins is fragile' issue.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:29:18.768621+00:00— report_created — created