Skip to content

Commit 6a7a7e5

Browse files
Neilmdboom
Neil
authored andcommitted
Add Py_hash_t type for compiling against Python 3 on 32bit machines
1 parent 1ea3e1f commit 6a7a7e5

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

CXX/Python3/Config.hxx

+8
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,12 @@
107107
# define TEMPLATE_TYPENAME class
108108
#endif
109109

110+
111+
/* Need to fudge Py_hash_t types for python > 3.2 */
112+
113+
#if PY_VERSION_HEX < 0x030200A4
114+
typedef long Py_hash_t;
115+
typedef unsigned long Py_uhash_t;
116+
#endif
117+
110118
#endif // __PyCXX_config_hh__

CXX/Python3/ExtensionTypeBase.hxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace Py
8383
virtual Object rich_compare( const Object &, int );
8484
virtual Object repr();
8585
virtual Object str();
86-
virtual long hash();
86+
virtual Py_hash_t hash();
8787
virtual Object call( const Object &, const Object & );
8888
virtual Object iter();
8989
virtual PyObject *iternext();

CXX/Python3/Objects.hxx

+3-3
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ namespace Py
270270
return Object( PyObject_GetItem( p, *key ), true );
271271
}
272272

273-
long hashValue() const
273+
Py_hash_t hashValue() const
274274
{
275275
return PyObject_Hash( p );
276276
}
@@ -1159,7 +1159,7 @@ namespace Py
11591159
return the_item.getItem( key );
11601160
}
11611161

1162-
long hashValue() const
1162+
Py_hash_t hashValue() const
11631163
{
11641164
return the_item.hashValue();
11651165
}
@@ -2417,7 +2417,7 @@ namespace Py
24172417
return the_item.getItem( k );
24182418
}
24192419

2420-
long hashValue() const
2420+
Py_hash_t hashValue() const
24212421
{
24222422
return the_item.hashValue();
24232423
}

CXX/Python3/cxx_extensions.cxx

+3-3
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ extern "C"
225225
static PyObject *rich_compare_handler( PyObject *, PyObject *, int );
226226
static PyObject *repr_handler( PyObject * );
227227
static PyObject *str_handler( PyObject * );
228-
static long hash_handler( PyObject * );
228+
static Py_hash_t hash_handler( PyObject * );
229229
static PyObject *call_handler( PyObject *, PyObject *, PyObject * );
230230
static PyObject *iter_handler( PyObject * );
231231
static PyObject *iternext_handler( PyObject * );
@@ -714,7 +714,7 @@ extern "C" PyObject *str_handler( PyObject *self )
714714
}
715715
}
716716

717-
extern "C" long hash_handler( PyObject *self )
717+
extern "C" Py_hash_t hash_handler( PyObject *self )
718718
{
719719
try
720720
{
@@ -1191,7 +1191,7 @@ Py::Object PythonExtensionBase::str()
11911191
return Py::None();
11921192
}
11931193

1194-
long PythonExtensionBase::hash()
1194+
Py_hash_t PythonExtensionBase::hash()
11951195
{
11961196
missing_method( hash );
11971197
return -1; }

0 commit comments

Comments
 (0)