Repository navigation
Commit 04a4045
committed
Fix json.encode of a dict keyed by a plain str Enum
Encoding a dict whose keys are members of a plain enum.Enum with str values
raised "Only dicts with str-like or number-like keys are supported", even
though dict[MyEnum, int] is an accepted decode type and both msgpack.encode and
to_builtins handle such keys. The asymmetry came from json_encode_enum routing
a key's underlying value through json_encode_dict_key_noinline, which only
handles non-str keys (str keys are fast-pathed elsewhere) and therefore
rejected the str value.
Write a str enum value straight to the key with json_encode_str; non-str values
keep going through json_encode_dict_key_noinline as before.1 parent 9ddc0e9 commit 04a4045
2 files changed
Lines changed: 54 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14153 | 14153 | | |
14154 | 14154 | | |
14155 | 14155 | | |
14156 | | - | |
14157 | | - | |
14158 | | - | |
| 14156 | + | |
| 14157 | + | |
| 14158 | + | |
| 14159 | + | |
| 14160 | + | |
| 14161 | + | |
| 14162 | + | |
| 14163 | + | |
| 14164 | + | |
| 14165 | + | |
| 14166 | + | |
| 14167 | + | |
| 14168 | + | |
| 14169 | + | |
14159 | 14170 | | |
14160 | 14171 | | |
14161 | 14172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2019 | 2019 | | |
2020 | 2020 | | |
2021 | 2021 | | |
| 2022 | + | |
2022 | 2023 | | |
2023 | 2024 | | |
2024 | 2025 | | |
| |||
2037 | 2038 | | |
2038 | 2039 | | |
2039 | 2040 | | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
2040 | 2080 | | |
2041 | 2081 | | |
2042 | 2082 | | |
| |||
0 commit comments