Replace use of function deprecated in ICU 71

This commit is contained in:
Kovid Goyal 2022-04-22 20:32:53 +05:30
parent b8b21e4ada
commit 86fc424ff6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 10 additions and 2 deletions

View File

@ -499,10 +499,13 @@ icu_Collator_clone(icu_Collator *self, PyObject *args)
{ {
UCollator *collator; UCollator *collator;
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
int32_t bufsize = -1;
icu_Collator *clone; 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)) { if (collator == NULL || U_FAILURE(status)) {
PyErr_SetString(PyExc_Exception, "Failed to create collator."); PyErr_SetString(PyExc_Exception, "Failed to create collator.");

View File

@ -11,6 +11,7 @@
#define PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN
#include <Python.h> #include <Python.h>
#include <unicode/uversion.h> #include <unicode/uversion.h>
#include <unicode/uvernum.h>
#include <unicode/utypes.h> #include <unicode/utypes.h>
#include <unicode/uclean.h> #include <unicode/uclean.h>
#include <unicode/utf16.h> #include <unicode/utf16.h>

View File

@ -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; } if (!PyCapsule_CheckExact(collator)) { PyErr_SetString(PyExc_TypeError, "Collator must be a capsule"); return -1; }
col = (UCollator*)PyCapsule_GetPointer(collator, NULL); col = (UCollator*)PyCapsule_GetPointer(collator, NULL);
if (col == NULL) return -1; 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); self->collator = ucol_safeClone(col, NULL, NULL, &status);
#endif
col = NULL; col = NULL;
if (U_FAILURE(status)) { self->collator = NULL; PyErr_SetString(PyExc_ValueError, u_errorName(status)); return -1; } if (U_FAILURE(status)) { self->collator = NULL; PyErr_SetString(PyExc_ValueError, u_errorName(status)); return -1; }