Skip to content
Snippets Groups Projects
Commit aea22686 authored by David Gobbi's avatar David Gobbi
Browse files

BUG 14037: Add hash function to PyVTKClass type.

In Python 2.7, python was calling PyType_Ready() on the PyVTKClass
type in order to get its superclasses whenever hash() was called.
This raised an exception because this type predates the type/class
refinements that occurred in python 2.2.  A simple fix is to add
tp_hash to the type.

Change-Id: I9f2ec46839bd8409bbc3bfadd3a7ac8791d36ca3
parent 9b1a0f4f
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,17 @@ static PyObject *PyVTKClass_Repr(PyObject *op)
return PyString_FromString(buf);
}
//--------------------------------------------------------------------
static long PyVTKClass_Hash(PyObject *op)
{
size_t y = reinterpret_cast<size_t>(op);
y = (y >> 4) | (y << (8 * sizeof(op) - 4));
long x = static_cast<long>(y);
if (x == -1) { x = -2; }
return x;
}
//--------------------------------------------------------------------
static PyObject *PyVTKClass_Call(PyObject *op, PyObject *arg, PyObject *kw)
{
......@@ -398,7 +409,7 @@ PyTypeObject PyVTKClass_Type = {
0, // tp_as_number
0, // tp_as_sequence
0, // tp_as_mapping
0, // tp_hash
PyVTKClass_Hash, // tp_hash
PyVTKClass_Call, // tp_call
PyVTKClass_String, // tp_string
PyVTKClass_GetAttr, // tp_getattro
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment