Commit 8f9e721
committed
py/objtype: Fix type hashing with metaclass operator support.
When MICROPY_PY_METACLASS_OPS is enabled, type_unary_op() intercepts
all unary operations on type objects. Previously it returned MP_OBJ_NULL
for types with the standard metaclass, which prevented the default hash
implementation from being used.
This fix ensures that __hash__ always works for type objects by returning
the default identity-based hash when the metaclass doesn't override it.
Fixes TypeError: unsupported type for __hash__: 'type'
Signed-off-by: Andrew Leech <[email protected]>1 parent 609b8aa commit 8f9e721
2 files changed
+15
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1274 | 1274 | | |
1275 | 1275 | | |
1276 | 1276 | | |
1277 | | - | |
| 1277 | + | |
| 1278 | + | |
1278 | 1279 | | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
1279 | 1284 | | |
1280 | 1285 | | |
1281 | 1286 | | |
| |||
1313 | 1318 | | |
1314 | 1319 | | |
1315 | 1320 | | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
1316 | 1327 | | |
1317 | 1328 | | |
1318 | 1329 | | |
| |||
0 commit comments