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
..
2023-04-27 18:03:06 +10:00
2023-06-08 17:54:24 +10:00
2025-06-10 15:32:54 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-03-09 12:13:12 +11:00
2023-03-09 12:13:12 +11:00
2023-03-09 12:13:12 +11:00
2022-12-16 11:44:10 +11:00
2025-10-04 00:19:40 +10:00
2025-10-04 00:19:40 +10:00
2023-07-13 13:50:50 +10:00
2025-10-04 00:19:40 +10:00
2023-06-08 17:54:24 +10:00
2025-04-21 17:37:39 +10:00
2025-10-04 00:19:40 +10:00
2023-06-08 17:54:24 +10:00
2024-02-20 12:12:28 +11:00
2023-06-08 17:54:24 +10:00
2023-05-19 12:35:12 +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
2024-08-19 14:18:34 +10:00
2024-08-19 14:18:34 +10:00
2024-07-25 12:27:33 +10:00
2024-04-22 11:50:52 +10:00
2024-04-22 11:50:52 +10:00
2024-04-22 11:50:52 +10:00
2024-01-05 15:08:33 +11:00
2022-08-11 23:18:02 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2022-11-08 23:09:22 +11:00
2022-08-11 23:18:02 +10:00
2022-08-11 23:18:02 +10:00
2024-04-22 11:50:52 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2022-08-11 23:18:02 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2022-09-26 00:54:18 +10:00
2024-05-28 10:58:37 +10:00
2024-05-28 10:58:37 +10:00
2024-05-28 10:58:37 +10:00
2025-10-04 00:19:40 +10:00
2025-07-29 09:41:10 +10:00
2023-06-08 17:54:24 +10:00
2023-05-19 13:44:00 +10:00
2025-07-29 09:41:10 +10:00
2025-07-29 09:41:10 +10:00
2023-06-08 17:54:24 +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-03-18 14:10:14 +11:00
2024-11-04 11:22:43 +11:00
2024-03-19 10:08:32 +11:00
2024-03-19 10:08:32 +11:00
2024-03-18 14:10:14 +11:00
2023-06-08 17:54:24 +10:00
2022-11-25 12:46:14 +11:00
2022-11-25 12:46:14 +11:00
2025-11-21 13:28:28 +11:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2025-10-02 00:37:29 +10:00
2023-10-09 09:46:02 +11:00
2025-10-04 00:19:40 +10:00
2022-11-28 11:23:22 +11:00
2022-08-06 11:32:58 -05: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
2024-05-27 13:56:55 +10:00
2024-05-27 13:56:55 +10:00
2024-06-21 16:23:08 +10:00
2024-05-27 13:56:55 +10:00
2024-05-27 13:56:55 +10:00
2024-05-27 13:56:55 +10:00
2024-06-21 16:23:08 +10:00
2024-05-27 13:56:55 +10:00
2023-05-03 13:21:18 +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
2023-06-08 17:54:24 +10:00
2024-03-07 16:25:17 +11:00
2024-03-07 16:25:17 +11:00
2023-01-23 13:03:51 +11:00
2024-03-07 16:25:17 +11:00
2024-03-07 16:25:17 +11:00
2024-03-07 16:25:17 +11: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
2024-07-01 13:52:59 +10:00
2024-03-07 16:25:17 +11:00
2024-03-07 16:25:17 +11:00
2024-03-07 16:25:17 +11:00
2024-06-24 14:07:00 +10:00
2024-06-24 14:07:00 +10:00
2024-09-02 14:15:49 +10:00
2024-09-02 14:15:49 +10:00
2024-06-24 14:07:00 +10:00
2023-06-01 15:11:06 +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
2023-05-19 13:44:00 +10:00
2025-10-04 00:19:40 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-01-20 16:31:37 +11:00
2023-01-20 16:31:37 +11:00
2025-10-04 00:19:40 +10:00
2022-09-19 23:22:46 +10:00
2025-04-21 17:37:39 +10:00
2023-06-08 17:54:24 +10:00
2025-01-26 22:51:50 +11:00
2023-05-19 13:33:54 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10: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
2023-11-21 22:28:57 +11:00
2024-05-28 10:50:57 +10:00
2024-05-28 10:50:57 +10:00
2025-07-24 14:55:34 +10:00
2025-07-24 14:55:34 +10:00
2023-06-01 13:01:07 +10:00
2023-06-01 13:01:07 +10:00
2023-06-01 13:01:07 +10:00
2024-05-28 10:58:37 +10:00
2023-06-08 17:54:24 +10:00
2025-03-02 22:15:31 +11:00
2024-05-28 10:58:37 +10:00
2024-05-28 10:58:37 +10:00
2024-09-26 23:39:06 +10:00
2023-09-01 14:31:57 +10:00
2025-10-06 15:07:34 +11:00
2025-05-13 12:16:35 +10:00
2023-01-20 17:54:32 +11:00
2024-05-28 10:58:37 +10:00
2024-05-28 10:58:37 +10:00
2024-06-06 17:34:28 +10:00
2023-05-19 13:44:00 +10:00
2025-03-02 22:15:31 +11:00
2023-06-08 17:54:24 +10:00
2023-09-01 14:50:49 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2024-07-25 13:07:42 +10:00
2025-02-11 16:51:50 +11:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10: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
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2023-06-08 17:54:24 +10:00
2024-09-06 17:00:35 +10:00
2024-09-06 17:00:35 +10:00
2024-09-06 17:00:35 +10:00
2025-10-04 00:19:40 +10:00
2023-06-08 17:54:24 +10:00
2025-08-15 00:36:27 +10:00
2024-01-31 12:56:29 +11:00
2025-10-04 00:19:40 +10:00
2023-04-27 18:03:06 +10:00