mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace use of function deprecated in ICU 71
This commit is contained in:
parent
b8b21e4ada
commit
86fc424ff6
@ -499,10 +499,13 @@ icu_Collator_clone(icu_Collator *self, PyObject *args)
|
||||
{
|
||||
UCollator *collator;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t bufsize = -1;
|
||||
icu_Collator *clone;
|
||||
|
||||
collator = ucol_safeClone(self->collator, NULL, &bufsize, &status);
|
||||
#if U_ICU_VERSION_MAJOR_NUM > 70
|
||||
collator = ucol_clone(self->collator, &status);
|
||||
#else
|
||||
collator = ucol_safeClone(self->collator, NULL, NULL, &status);
|
||||
#endif
|
||||
|
||||
if (collator == NULL || U_FAILURE(status)) {
|
||||
PyErr_SetString(PyExc_Exception, "Failed to create collator.");
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include <Python.h>
|
||||
#include <unicode/uversion.h>
|
||||
#include <unicode/uvernum.h>
|
||||
#include <unicode/utypes.h>
|
||||
#include <unicode/uclean.h>
|
||||
#include <unicode/utf16.h>
|
||||
|
@ -364,7 +364,11 @@ Matcher_init(Matcher *self, PyObject *args, PyObject *kwds)
|
||||
if (!PyCapsule_CheckExact(collator)) { PyErr_SetString(PyExc_TypeError, "Collator must be a capsule"); return -1; }
|
||||
col = (UCollator*)PyCapsule_GetPointer(collator, NULL);
|
||||
if (col == NULL) return -1;
|
||||
#if U_ICU_VERSION_MAJOR_NUM > 70
|
||||
self->collator = ucol_clone(self->collator, &status);
|
||||
#else
|
||||
self->collator = ucol_safeClone(col, NULL, NULL, &status);
|
||||
#endif
|
||||
col = NULL;
|
||||
if (U_FAILURE(status)) { self->collator = NULL; PyErr_SetString(PyExc_ValueError, u_errorName(status)); return -1; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user