Skip to content

Commit 6e4e845

Browse files
committedSep 21, 2016
pyspatialite: port to python3
1 parent 724ea44 commit 6e4e845

File tree

12 files changed

+807
-469
lines changed

12 files changed

+807
-469
lines changed
 

‎python/ext-libs/pyspatialite/src/cache.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
* 3. This notice may not be removed or altered from any source distribution.
2222
*/
2323

24-
#include "sqlitecompat.h"
2524
#include "cache.h"
2625
#include <limits.h>
2726

@@ -217,8 +216,6 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
217216
pysqlite_Node* ptr;
218217
PyObject* prevkey;
219218
PyObject* nextkey;
220-
PyObject* fmt_args;
221-
PyObject* template;
222219
PyObject* display_str;
223220

224221
ptr = self->first;
@@ -229,36 +226,21 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
229226
} else {
230227
prevkey = Py_None;
231228
}
232-
Py_INCREF(prevkey);
233229

234230
if (ptr->next) {
235231
nextkey = ptr->next->key;
236232
} else {
237233
nextkey = Py_None;
238234
}
239-
Py_INCREF(nextkey);
240235

241-
fmt_args = Py_BuildValue("OOO", prevkey, ptr->key, nextkey);
242-
if (!fmt_args) {
243-
return NULL;
244-
}
245-
template = PyString_FromString("%s <- %s ->%s\n");
246-
if (!template) {
247-
Py_DECREF(fmt_args);
248-
return NULL;
249-
}
250-
display_str = PyString_Format(template, fmt_args);
251-
Py_DECREF(template);
252-
Py_DECREF(fmt_args);
236+
display_str = PyUnicode_FromFormat("%S <- %S -> %S\n",
237+
prevkey, ptr->key, nextkey);
253238
if (!display_str) {
254239
return NULL;
255240
}
256241
PyObject_Print(display_str, stdout, Py_PRINT_RAW);
257242
Py_DECREF(display_str);
258243

259-
Py_DECREF(prevkey);
260-
Py_DECREF(nextkey);
261-
262244
ptr = ptr->next;
263245
}
264246

@@ -283,7 +265,7 @@ PyTypeObject pysqlite_NodeType = {
283265
0, /* tp_print */
284266
0, /* tp_getattr */
285267
0, /* tp_setattr */
286-
0, /* tp_compare */
268+
0, /* tp_reserved */
287269
0, /* tp_repr */
288270
0, /* tp_as_number */
289271
0, /* tp_as_sequence */
@@ -325,7 +307,7 @@ PyTypeObject pysqlite_CacheType = {
325307
0, /* tp_print */
326308
0, /* tp_getattr */
327309
0, /* tp_setattr */
328-
0, /* tp_compare */
310+
0, /* tp_reserved */
329311
0, /* tp_repr */
330312
0, /* tp_as_number */
331313
0, /* tp_as_sequence */

0 commit comments

Comments
 (0)
Please sign in to comment.