Skip to content

Commit b2b09b7

Browse files
WillAydjreback
authored andcommitted
Removed compat directives from ujson (#26211)
1 parent 3de7139 commit b2b09b7

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

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

+2-27
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ npy_int64 get_nat(void) { return NPY_MIN_INT64; }
6262
typedef void *(*PFN_PyTypeToJSON)(JSOBJ obj, JSONTypeContext *ti,
6363
void *outValue, size_t *_outLen);
6464

65-
#if (PY_VERSION_HEX < 0x02050000)
66-
typedef ssize_t Py_ssize_t;
67-
#endif
68-
6965
typedef struct __NpyArrContext {
7066
PyObject *array;
7167
char *dataptr;
@@ -153,12 +149,7 @@ enum PANDAS_FORMAT { SPLIT, RECORDS, INDEX, COLUMNS, VALUES };
153149

154150
int PdBlock_iterNext(JSOBJ, JSONTypeContext *);
155151

156-
// import_array() compat
157-
#if (PY_VERSION_HEX >= 0x03000000)
158152
void *initObjToJSON(void)
159-
#else
160-
void initObjToJSON(void)
161-
#endif
162153
{
163154
PyObject *mod_pandas;
164155
PyObject *mod_nattype;
@@ -426,14 +417,12 @@ static void *PyUnicodeToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
426417
PyObject *obj, *newObj;
427418
obj = (PyObject *)_obj;
428419

429-
#if (PY_VERSION_HEX >= 0x03030000)
430420
if (PyUnicode_IS_COMPACT_ASCII(obj)) {
431421
Py_ssize_t len;
432422
char *data = (char*)PyUnicode_AsUTF8AndSize(obj, &len);
433423
*_outLen = len;
434424
return data;
435425
}
436-
#endif
437426

438427
newObj = PyUnicode_AsUTF8String(obj);
439428

@@ -720,15 +709,7 @@ int NpyArr_iterNextItem(JSOBJ obj, JSONTypeContext *tc) {
720709

721710
NpyArr_freeItemValue(obj, tc);
722711

723-
#if NPY_API_VERSION < 0x00000007
724-
if (PyArray_ISDATETIME(npyarr->array)) {
725-
PRINTMARK();
726-
GET_TC(tc)
727-
->itemValue = PyArray_ToScalar(npyarr->dataptr, npyarr->array);
728-
} else if (PyArray_ISNUMBER(npyarr->array)) // NOLINT
729-
#else
730-
if (PyArray_ISNUMBER(npyarr->array) || PyArray_ISDATETIME(npyarr->array)) // NOLINT
731-
#endif
712+
if (PyArray_ISNUMBER(npyarr->array) || PyArray_ISDATETIME(npyarr->array))
732713
{
733714
PRINTMARK();
734715
GET_TC(tc)->itemValue = obj;
@@ -1619,13 +1600,7 @@ char **NpyArr_encodeLabels(PyArrayObject *labels, JSONObjectEncoder *enc,
16191600
type_num = PyArray_TYPE(labels);
16201601

16211602
for (i = 0; i < num; i++) {
1622-
#if NPY_API_VERSION < 0x00000007
1623-
if (PyTypeNum_ISDATETIME(type_num)) {
1624-
item = PyArray_ToScalar(dataptr, labels);
1625-
} else if (PyTypeNum_ISNUMBER(type_num)) // NOLINT
1626-
#else
1627-
if (PyTypeNum_ISDATETIME(type_num) || PyTypeNum_ISNUMBER(type_num)) // NOLINT
1628-
#endif
1603+
if (PyTypeNum_ISDATETIME(type_num) || PyTypeNum_ISNUMBER(type_num))
16291604
{
16301605
item = (PyObject *)labels;
16311606
pyenc->npyType = type_num;

0 commit comments

Comments
 (0)