Damien George
128420359e
py/objdict: Implement bool and len unary ops for dict views.
...
Currently, dict views (eg `dict.keys()`, `dict.values()`) do not implement
the `bool` or `len` unary operations. That may seem like a reasonable
omission for MicroPython to keep code size down, but it actually leads to
silently incorrect bool operations, because by default things are true.
Eg we currently have:
>>> bool(dict().keys())
True
which is wrong, it should be `False` because the dict is empty.
This commit implements `bool` and `len` unary operations on dict views by
simply delegating to the existing dict unary op function.
Fixes issue #12385 .
Signed-off-by: Damien George <damien@micropython.org >
2025-11-21 13:28:28 +11:00
..
2025-06-10 15:32:54 +10:00
2025-10-04 00:19:40 +10:00
2025-10-04 00:19:40 +10:00
2025-10-04 00:19:40 +10:00
2025-04-21 17:37:39 +10:00
2025-10-04 00:19:40 +10:00
2025-07-28 23:58:46 +10:00
2025-09-26 13:34:55 +10:00
2025-10-04 00:19:40 +10:00
2025-10-04 00:19:40 +10:00
2025-07-16 00:12:47 +10:00
2025-10-04 00:19:40 +10:00
2025-07-29 09:41:10 +10:00
2025-07-29 09:41:10 +10:00
2025-07-29 09:41:10 +10:00
2025-10-04 00:19:40 +10:00
2025-10-04 00:19:40 +10:00
2025-10-04 00:19:40 +10:00
2024-11-04 11:22:43 +11:00
2025-11-21 13:28:28 +11:00
2025-10-02 00:37:29 +10:00
2025-10-04 00:19:40 +10:00
2025-07-08 11:03:22 -04:00
2025-07-08 11:03:22 -04:00
2025-07-18 10:59:21 -04:00
2025-10-01 11:54:26 +10:00
2025-07-18 10:59:21 -04:00
2025-02-11 16:51:50 +11:00
2025-02-11 16:51:50 +11:00
2025-02-11 16:51:50 +11:00
2025-10-04 00:19:40 +10:00
2025-10-04 00:19:40 +10:00
2025-09-30 11:04:05 +10:00
2025-01-26 22:54:58 +11:00
2025-08-28 11:31:03 +10:00
2025-09-28 23:23:11 +10:00
2025-09-28 23:23:11 +10:00
2025-09-28 23:23:11 +10:00
2025-08-15 00:23:16 +10:00
2025-06-17 10:15:59 +10:00
2025-08-15 00:23:16 +10:00
2025-08-15 00:23:16 +10:00
2025-08-15 00:23:16 +10:00
2025-10-04 00:19:40 +10:00
2025-08-15 00:23:16 +10:00
2025-08-15 00:23:16 +10:00
2025-08-15 00:23:16 +10:00
2025-08-15 00:23:16 +10:00
2025-01-26 22:54:58 +11:00
2025-10-04 00:19:40 +10:00
2025-10-04 00:19:40 +10:00
2025-04-21 17:37:39 +10:00
2025-01-26 22:51:50 +11:00
2025-10-04 00:19:40 +10:00
2025-10-04 00:19:40 +10:00
2025-10-02 00:37:29 +10:00
2025-07-24 14:55:34 +10:00
2025-07-24 14:55:34 +10:00
2025-03-02 22:15:31 +11:00
2024-09-26 23:39:06 +10:00
2025-10-06 15:07:34 +11:00
2025-05-13 12:16:35 +10:00
2025-03-02 22:15:31 +11:00
2025-02-11 16:51:50 +11:00
2025-10-02 00:37:29 +10:00
2025-10-04 00:19:40 +10:00
2025-07-22 23:22:05 +10:00
2025-10-04 00:19:40 +10:00
2025-08-15 00:36:27 +10:00
2025-10-04 00:19:40 +10:00