Skip to content

Commit 5672766

Browse files
Backport PR #42360: BUG: fixes PyPy build (do not use _PyHASH_Imag) (#42373)
1 parent 263cc6c commit 5672766

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

doc/source/whatsnew/v1.3.1.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ including other versions of pandas.
1414

1515
Fixed regressions
1616
~~~~~~~~~~~~~~~~~
17-
-
17+
- Pandas could not be built on PyPy (:issue:`42355`)
1818
-
1919

2020
.. ---------------------------------------------------------------------------

pandas/_libs/src/klib/khash_python.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,16 @@ Py_hash_t PANDAS_INLINE floatobject_hash(PyFloatObject* key) {
272272
}
273273

274274

275+
#define _PandasHASH_IMAG 1000003UL
276+
275277
// replaces _Py_HashDouble with _Pandas_HashDouble
276278
Py_hash_t PANDAS_INLINE complexobject_hash(PyComplexObject* key) {
277279
Py_uhash_t realhash = (Py_uhash_t)_Pandas_HashDouble(key->cval.real);
278280
Py_uhash_t imaghash = (Py_uhash_t)_Pandas_HashDouble(key->cval.imag);
279281
if (realhash == (Py_uhash_t)-1 || imaghash == (Py_uhash_t)-1) {
280282
return -1;
281283
}
282-
Py_uhash_t combined = realhash + _PyHASH_IMAG * imaghash;
284+
Py_uhash_t combined = realhash + _PandasHASH_IMAG * imaghash;
283285
if (combined == (Py_uhash_t)-1) {
284286
return -2;
285287
}

0 commit comments

Comments
 (0)