|
| 1 | +diff --git a/pandas/_libs/src/klib/khash_python.h b/pandas/_libs/src/klib/khash_python.h |
| 2 | +index 5ae3c19..b9c6784 100644 |
| 3 | +--- a/pandas/_libs/src/klib/khash_python.h |
| 4 | ++++ b/pandas/_libs/src/klib/khash_python.h |
| 5 | +@@ -178,28 +178,30 @@ int PANDAS_INLINE floatobject_cmp(PyFloatObject* a, PyFloatObject* b){ |
| 6 | + // PyObject_RichCompareBool for complexobjects has a different behavior |
| 7 | + // needs to be replaced |
| 8 | + int PANDAS_INLINE complexobject_cmp(PyComplexObject* a, PyComplexObject* b){ |
| 9 | ++ Py_complex a_cval = PyComplex_AsCComplex((PyObject*)a); |
| 10 | ++ Py_complex b_cval = PyComplex_AsCComplex((PyObject*)b); |
| 11 | + return ( |
| 12 | +- Py_IS_NAN(a->cval.real) && |
| 13 | +- Py_IS_NAN(b->cval.real) && |
| 14 | +- Py_IS_NAN(a->cval.imag) && |
| 15 | +- Py_IS_NAN(b->cval.imag) |
| 16 | ++ Py_IS_NAN(a_cval.real) && |
| 17 | ++ Py_IS_NAN(b_cval.real) && |
| 18 | ++ Py_IS_NAN(a_cval.imag) && |
| 19 | ++ Py_IS_NAN(b_cval.imag) |
| 20 | + ) |
| 21 | + || |
| 22 | + ( |
| 23 | +- Py_IS_NAN(a->cval.real) && |
| 24 | +- Py_IS_NAN(b->cval.real) && |
| 25 | +- a->cval.imag == b->cval.imag |
| 26 | ++ Py_IS_NAN(a_cval.real) && |
| 27 | ++ Py_IS_NAN(b_cval.real) && |
| 28 | ++ a_cval.imag == b_cval.imag |
| 29 | + ) |
| 30 | + || |
| 31 | + ( |
| 32 | +- a->cval.real == b->cval.real && |
| 33 | +- Py_IS_NAN(a->cval.imag) && |
| 34 | +- Py_IS_NAN(b->cval.imag) |
| 35 | ++ a_cval.real == b_cval.real && |
| 36 | ++ Py_IS_NAN(a_cval.imag) && |
| 37 | ++ Py_IS_NAN(b_cval.imag) |
| 38 | + ) |
| 39 | + || |
| 40 | + ( |
| 41 | +- a->cval.real == b->cval.real && |
| 42 | +- a->cval.imag == b->cval.imag |
| 43 | ++ a_cval.real == b_cval.real && |
| 44 | ++ a_cval.imag == b_cval.imag |
| 45 | + ); |
| 46 | + } |
| 47 | + |
| 48 | +@@ -276,8 +278,9 @@ Py_hash_t PANDAS_INLINE floatobject_hash(PyFloatObject* key) { |
| 49 | + |
| 50 | + // replaces _Py_HashDouble with _Pandas_HashDouble |
| 51 | + Py_hash_t PANDAS_INLINE complexobject_hash(PyComplexObject* key) { |
| 52 | +- Py_uhash_t realhash = (Py_uhash_t)_Pandas_HashDouble(key->cval.real); |
| 53 | +- Py_uhash_t imaghash = (Py_uhash_t)_Pandas_HashDouble(key->cval.imag); |
| 54 | ++ Py_complex cval = PyComplex_AsCComplex((PyObject*)key); |
| 55 | ++ Py_uhash_t realhash = (Py_uhash_t)_Pandas_HashDouble(cval.real); |
| 56 | ++ Py_uhash_t imaghash = (Py_uhash_t)_Pandas_HashDouble(cval.imag); |
| 57 | + if (realhash == (Py_uhash_t)-1 || imaghash == (Py_uhash_t)-1) { |
| 58 | + return -1; |
| 59 | + } |
1 | 60 | diff --git a/pandas/io/common.py b/pandas/io/common.py
|
2 | 61 | index f31de63..1858912 100644
|
3 | 62 | --- a/pandas/io/common.py
|
|
0 commit comments