Skip to content

Commit 9df5ab7

Browse files
tacaswelljreback
authored andcommitted
FIX: const-correctness in numpy helpers (#19749)
In python 3.7 the return type of PyUnicode_AsUTF8 changed from (char *) to (const char *). PyUnicode_FromString also takes (const char *) as input, also be explicit about that. https://bugs.python.org/issue28769 commit 2a404b63d48d73bbaa007d89efb7a01048475acd in cpython
1 parent 5bb5e33 commit 9df5ab7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/_libs/src/numpy_helper.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ PANDAS_INLINE PyObject* get_value_1d(PyArrayObject* ap, Py_ssize_t i) {
3232

3333
// returns ASCII or UTF8 (py3) view on python str
3434
// python object owns memory, should not be freed
35-
PANDAS_INLINE char* get_c_string(PyObject* obj) {
35+
PANDAS_INLINE const char* get_c_string(PyObject* obj) {
3636
#if PY_VERSION_HEX >= 0x03000000
3737
return PyUnicode_AsUTF8(obj);
3838
#else
3939
return PyString_AsString(obj);
4040
#endif
4141
}
4242

43-
PANDAS_INLINE PyObject* char_to_string(char* data) {
43+
PANDAS_INLINE PyObject* char_to_string(const char* data) {
4444
#if PY_VERSION_HEX >= 0x03000000
4545
return PyUnicode_FromString(data);
4646
#else

0 commit comments

Comments
 (0)