mypyc: Fix overflow in id function (CPyTagged_Id) (#12332)
In CPython, the id of an object is its address. It's computed by
converting the pointer to an unsigned integer (PyLong_FromVoidPtr). A
similar logic is present here, pointer is converted to a Py_ssize_t and
CPyTagged_FromSsize_t is called with that integer.
There is a problem with that approach: Py_ssize_t cannot hold every
pointer value. Sometimes overflow happens and CPyTagged_FromSsize_t is
called with a negative integer.
With the new approach, the number is checked: If it fits in a
Py_ssize_t, CPyTagged_FromSsize_t is called. If not, it is directly
converted to a PyObject using PyLong_FromVoidPtr.