)]}'
{
  "commit": "09520295d5591cc18799f4556c9465af76e8e886",
  "tree": "612b1d06571b35f663f51d4f0488edbf978deef5",
  "parents": [
    "c76426e811c0f95c227266acec0bcf5ba1e9b44b"
  ],
  "author": {
    "name": "Ryan Heard",
    "email": "ryanwheard@gmail.com",
    "time": "Fri Nov 13 10:30:32 2026 -0500"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Fri Nov 13 15:30:32 2026 +0000"
  },
  "message": "[mypyc] Fix OverflowError when a native `__hash__` returns a large int (#22453)\n\nFixes mypyc/mypyc#1253\n\nThe `tp_hash` slot of a native class converted the value returned by\n`__hash__` with `CPyTagged_AsSsize_t()`, so an int that doesn\u0027t fit in\n`Py_hash_t` made `hash()` raise `OverflowError`. CPython\u0027s\n`slot_tp_hash`, which a class defined in Python uses, accepts any int\nand hashes one that doesn\u0027t fit again with `int.__hash__`.\n\n`generate_hash_wrapper()` now does the same:\n\n- A short int is still handled inline, with -1 changed to -2 as before.\n- A long int goes through the new `CPy_HashFromResult()` in\n`generic_ops.c`, which does what `slot_tp_hash`\ndoes with the result: an int that fits in `Py_hash_t` is used as is, a\nlarger one is hashed again, and\nanything that isn\u0027t an int raises `TypeError: __hash__ method should\nreturn an integer`.\n- Other return types are boxed if needed and passed to\n`CPy_HashFromResult()`. With `-\u003e Any`, a result that\nisn\u0027t an int used to raise `TypeError: an integer is required`. A\n`__hash__` declared to return a native int\ntype such as `i64` segfaulted (or raised `SystemError` if it returned\n0), because the slot passed the C value\n  to `PyLong_AsSsize_t()` as an object pointer, but now this works.\n\nThe new run test `testDundersHashResult` covers `-\u003e int` and `-\u003e Any`\nwith values that fit in `Py_hash_t`, -1, values that don\u0027t fit, a long\nint that fits only on 64-bit platforms (2**62), `True` and results that\naren\u0027t ints, plus an `-\u003e i64` method that returns -1. The expected\nresults are the same on 32-bit platforms.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "e21d91926532991dbee9068817f30eb6d95ffdc2",
      "old_mode": 33188,
      "old_path": "mypyc/codegen/emitwrapper.py",
      "new_id": "92d32937872d98434c60711a4ee2b9d9afc6592f",
      "new_mode": 33188,
      "new_path": "mypyc/codegen/emitwrapper.py"
    },
    {
      "type": "modify",
      "old_id": "640761806174582102fd52f69d38ab84c5fdcd1b",
      "old_mode": 33188,
      "old_path": "mypyc/lib-rt/CPy.h",
      "new_id": "5151bb7cd745e328b2e0b4c66e9a701895a48456",
      "new_mode": 33188,
      "new_path": "mypyc/lib-rt/CPy.h"
    },
    {
      "type": "modify",
      "old_id": "09e6df362343a45c7836b900e59aaab81989d15a",
      "old_mode": 33188,
      "old_path": "mypyc/lib-rt/generic_ops.c",
      "new_id": "d421b53ebf0ada41ee7311416afa9deee92f98a5",
      "new_mode": 33188,
      "new_path": "mypyc/lib-rt/generic_ops.c"
    },
    {
      "type": "modify",
      "old_id": "ad9cd46bfd6c18679d9fb7e6d7c5e9b99be7e866",
      "old_mode": 33188,
      "old_path": "mypyc/test-data/run-dunders.test",
      "new_id": "4f932b684c8da1784e4be73c9e9ffb06075e6565",
      "new_mode": 33188,
      "new_path": "mypyc/test-data/run-dunders.test"
    }
  ]
}
