Skip to content

Commit 05f4926

Browse files
committed
hack: go back to use PyObject_* because of CI errors
1 parent 0f20b7d commit 05f4926

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

pandas/_libs/src/datetime/date_conversions.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ char *int64ToIso(int64_t value, NPY_DATETIMEUNIT valueUnit,
4949
pandas_datetime_to_datetimestruct(value, valueUnit, &dts);
5050

5151
*len = (size_t)get_datetime_iso_8601_strlen(0, base);
52-
char *result = PyMem_Malloc(*len);
52+
char *result = PyObject_Malloc(*len);
5353

5454
if (result == NULL) {
5555
PyErr_NoMemory();
@@ -60,7 +60,7 @@ char *int64ToIso(int64_t value, NPY_DATETIMEUNIT valueUnit,
6060
if (ret_code != 0) {
6161
PyErr_SetString(PyExc_ValueError,
6262
"Could not convert datetime value to string");
63-
PyMem_Free(result);
63+
PyObject_Free(result);
6464
}
6565

6666
// Note that get_datetime_iso_8601_strlen just gives a generic size
@@ -78,7 +78,7 @@ char *int64ToIsoDuration(int64_t value, size_t *len) {
7878

7979
// Max theoretical length of ISO Duration with 64 bit day
8080
// as the largest unit is 70 characters + 1 for a null terminator
81-
char *result = PyMem_Malloc(71);
81+
char *result = PyObject_Malloc(71);
8282
if (result == NULL) {
8383
PyErr_NoMemory();
8484
return NULL;
@@ -88,7 +88,7 @@ char *int64ToIsoDuration(int64_t value, size_t *len) {
8888
if (ret_code == -1) {
8989
PyErr_SetString(PyExc_ValueError,
9090
"Could not convert timedelta value to string");
91-
PyMem_Free(result);
91+
PyObject_Free(result);
9292
return NULL;
9393
}
9494

pandas/_libs/src/datetime/pd_datetime.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ static char *PyDateTimeToIso(PyObject *obj, NPY_DATETIMEUNIT base,
170170
}
171171

172172
*len = (size_t)get_datetime_iso_8601_strlen(0, base);
173-
char *result = PyMem_Malloc(*len);
173+
char *result = PyObject_Malloc(*len);
174174
// Check to see if PyDateTime has a timezone.
175175
// Don't convert to UTC if it doesn't.
176176
int is_tz_aware = 0;
177177
if (PyObject_HasAttrString(obj, "tzinfo")) {
178178
PyObject *offset = extract_utc_offset(obj);
179179
if (offset == NULL) {
180-
PyMem_Free(result);
180+
PyObject_Free(result);
181181
return NULL;
182182
}
183183
is_tz_aware = offset != Py_None;
@@ -188,7 +188,7 @@ static char *PyDateTimeToIso(PyObject *obj, NPY_DATETIMEUNIT base,
188188
if (ret != 0) {
189189
PyErr_SetString(PyExc_ValueError,
190190
"Could not convert datetime value to string");
191-
PyMem_Free(result);
191+
PyObject_Free(result);
192192
return NULL;
193193
}
194194

pandas/_libs/src/vendored/ujson/python/objToJSON.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ static const char *List_iterGetName(JSOBJ Py_UNUSED(obj),
10101010
//=============================================================================
10111011
static void Index_iterBegin(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc) {
10121012
GET_TC(tc)->index = 0;
1013-
GET_TC(tc)->cStr = PyMem_Malloc(CSTR_SIZE);
1013+
GET_TC(tc)->cStr = PyObject_Malloc(CSTR_SIZE);
10141014
if (!GET_TC(tc)->cStr) {
10151015
PyErr_NoMemory();
10161016
}
@@ -1060,7 +1060,7 @@ static void Series_iterBegin(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc) {
10601060
PyObjectEncoder *enc = (PyObjectEncoder *)tc->encoder;
10611061
GET_TC(tc)->index = 0;
10621062
enc->outputFormat = VALUES; // for contained series
1063-
GET_TC(tc)->cStr = PyMem_Malloc(CSTR_SIZE);
1063+
GET_TC(tc)->cStr = PyObject_Malloc(CSTR_SIZE);
10641064
if (!GET_TC(tc)->cStr) {
10651065
PyErr_NoMemory();
10661066
}
@@ -1115,7 +1115,7 @@ static void DataFrame_iterBegin(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc) {
11151115
PyObjectEncoder *enc = (PyObjectEncoder *)tc->encoder;
11161116
GET_TC(tc)->index = 0;
11171117
enc->outputFormat = VALUES; // for contained series & index
1118-
GET_TC(tc)->cStr = PyMem_Malloc(CSTR_SIZE);
1118+
GET_TC(tc)->cStr = PyObject_Malloc(CSTR_SIZE);
11191119
if (!GET_TC(tc)->cStr) {
11201120
PyErr_NoMemory();
11211121
}
@@ -1907,7 +1907,7 @@ static void Object_endTypeContext(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc) {
19071907
GET_TC(tc)->rowLabels = NULL;
19081908
NpyArr_freeLabels(GET_TC(tc)->columnLabels, GET_TC(tc)->columnLabelsLen);
19091909
GET_TC(tc)->columnLabels = NULL;
1910-
PyMem_Free(GET_TC(tc)->cStr);
1910+
PyObject_Free(GET_TC(tc)->cStr);
19111911
GET_TC(tc)->cStr = NULL;
19121912
PyObject_Free(tc->prv);
19131913
tc->prv = NULL;
@@ -1931,7 +1931,7 @@ static const char *Object_getBigNumStringValue(JSOBJ obj, JSONTypeContext *tc,
19311931
size_t *_outLen) {
19321932
PyObject *repr = PyObject_Str(obj);
19331933
const char *str = PyUnicode_AsUTF8AndSize(repr, (Py_ssize_t *)_outLen);
1934-
char *bytes = PyMem_Malloc(*_outLen + 1);
1934+
char *bytes = PyObject_Malloc(*_outLen + 1);
19351935
memcpy(bytes, str, *_outLen + 1);
19361936
GET_TC(tc)->cStr = bytes;
19371937

0 commit comments

Comments
 (0)