mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix more deprecation warnings in the test suite
This commit is contained in:
parent
dd8aa42c17
commit
618bf197e2
@ -162,7 +162,8 @@ def parse_extension(ext):
|
||||
def read_extensions():
|
||||
if hasattr(read_extensions, 'extensions'):
|
||||
return read_extensions.extensions
|
||||
ans = read_extensions.extensions = json.load(open(os.path.dirname(os.path.abspath(__file__)) + '/extensions.json', 'rb'))
|
||||
with open(os.path.dirname(os.path.abspath(__file__)) + '/extensions.json', 'rb') as f:
|
||||
ans = read_extensions.extensions = json.load(f)
|
||||
return ans
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* Distributed under terms of the GPL3 license.
|
||||
*/
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#define UNICODE
|
||||
#include <Python.h>
|
||||
#include <stdlib.h>
|
||||
@ -482,7 +483,7 @@ py_callback(void *ctx, int flags, const char *text, int text_length, int start_o
|
||||
|
||||
static PyObject*
|
||||
tokenize(PyObject *self, PyObject *args) {
|
||||
const char *text; int text_length, remove_diacritics = 1, flags = FTS5_TOKENIZE_DOCUMENT;
|
||||
const char *text; Py_ssize_t text_length, remove_diacritics = 1, flags = FTS5_TOKENIZE_DOCUMENT;
|
||||
if (!PyArg_ParseTuple(args, "s#|pi", &text, &text_length, &remove_diacritics, &flags)) return NULL;
|
||||
const char *targs[2] = {"remove_diacritics", "2"};
|
||||
if (!remove_diacritics) targs[1] = "0";
|
||||
@ -495,7 +496,7 @@ tokenize(PyObject *self, PyObject *args) {
|
||||
|
||||
static PyObject*
|
||||
stem(PyObject *self, PyObject *args) {
|
||||
const char *text, *lang = "en"; int text_length;
|
||||
const char *text, *lang = "en"; Py_ssize_t text_length;
|
||||
if (!PyArg_ParseTuple(args, "s#|s", &text, &text_length, &lang)) return NULL;
|
||||
Stemmer s(lang);
|
||||
if (!s) {
|
||||
@ -504,8 +505,9 @@ stem(PyObject *self, PyObject *args) {
|
||||
}
|
||||
int sz;
|
||||
const char* result = s.stem(text, text_length, &sz);
|
||||
Py_ssize_t a = sz;
|
||||
if (!result) return PyErr_NoMemory();
|
||||
return Py_BuildValue("s#", result, sz);
|
||||
return Py_BuildValue("s#", result, a);
|
||||
}
|
||||
|
||||
static PyMethodDef methods[] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user