forked from pool/python-recordclass
54 lines
2.6 KiB
Diff
54 lines
2.6 KiB
Diff
|
From 338044cbf771e5665a744d3b36b5d7edd126d16a Mon Sep 17 00:00:00 2001
|
||
|
From: Zaur Shibzukhov <szport@gmail.com>
|
||
|
Date: Mon, 31 Mar 2025 10:00:01 +0300
|
||
|
Subject: [PATCH] Fix #13 with litelist/litetuple get_subscript routine
|
||
|
|
||
|
---
|
||
|
examples/performance_cgc.ipynb | 32 ++++++++++++++++----------------
|
||
|
lib/recordclass/_litelist.c | 4 ++--
|
||
|
lib/recordclass/_litetuple.c | 4 ++--
|
||
|
3 files changed, 20 insertions(+), 20 deletions(-)
|
||
|
|
||
|
Index: recordclass-0.22.1/lib/recordclass/_litelist.c
|
||
|
===================================================================
|
||
|
--- recordclass-0.22.1.orig/lib/recordclass/_litelist.c
|
||
|
+++ recordclass-0.22.1/lib/recordclass/_litelist.c
|
||
|
@@ -484,13 +484,13 @@ litelist_subscript(PyLiteListObject* sel
|
||
|
if (PySlice_Check(item)) {
|
||
|
Py_ssize_t start, stop, step, slicelength;
|
||
|
|
||
|
- if (PySlice_GetIndicesEx(item, (PyTuple_GET_SIZE(self)), &start, &stop, &step, &slicelength) < 0)
|
||
|
+ if (PySlice_GetIndicesEx(item, (Py_SIZE(self)), &start, &stop, &step, &slicelength) < 0)
|
||
|
return NULL;
|
||
|
return litelist_slice(self, start, stop);
|
||
|
}
|
||
|
else {
|
||
|
PyErr_Format(PyExc_TypeError,
|
||
|
- "subscript must be integer, slice or string, but not %.200s",
|
||
|
+ "subscript must be integer or slice, but not %.200s",
|
||
|
Py_TYPE(item)->tp_name);
|
||
|
return NULL;
|
||
|
}
|
||
|
Index: recordclass-0.22.1/lib/recordclass/_litetuple.c
|
||
|
===================================================================
|
||
|
--- recordclass-0.22.1.orig/lib/recordclass/_litetuple.c
|
||
|
+++ recordclass-0.22.1/lib/recordclass/_litetuple.c
|
||
|
@@ -32,7 +32,7 @@ static PyTypeObject PyMLiteTuple_Type;
|
||
|
|
||
|
#define PyLiteTuple_GET_ITEM(op, i) (((PyLiteTupleObject *)(op))->ob_item[i])
|
||
|
#define PyLiteTuple_SET_ITEM(op, i, v) (((PyLiteTupleObject *)(op))->ob_item[i] = v)
|
||
|
-#define PyLiteTuple_GET_SIZE(seq) PyTuple_GET_SIZE(seq)
|
||
|
+#define PyLiteTuple_GET_SIZE(seq) Py_SIZE(seq)
|
||
|
|
||
|
#define PyLiteTuple_CheckExact(op) (Py_TYPE(op) == &PyLiteTuple_Type || Py_TYPE(op) == &PyMLiteTuple_Type)
|
||
|
#define PyLiteTuple_Check(op) (PyLiteTuple_CheckExact(op) || PyObject_IsInstance(op, (PyObject*)&PyLiteTuple_Type) || PyObject_IsInstance(op, (PyObject*)&PyMLiteTuple_Type))
|
||
|
@@ -417,7 +417,7 @@ litetuple_subscript(PyLiteTupleObject* s
|
||
|
if (PySlice_Check(item)) {
|
||
|
Py_ssize_t start, stop, step, slicelength;
|
||
|
|
||
|
- if (PySlice_GetIndicesEx(item, (PyTuple_GET_SIZE(self)), &start, &stop, &step, &slicelength) < 0)
|
||
|
+ if (PySlice_GetIndicesEx(item, (Py_SIZE(self)), &start, &stop, &step, &slicelength) < 0)
|
||
|
return NULL;
|
||
|
return litetuple_slice(self, start, stop);
|
||
|
}
|