Commit 3a4fd3f8 authored by Andi Vajda's avatar Andi Vajda
Browse files

added wrapper for u_cleanup/u_init sequence as ResourceBundle.resetICU()

parent d599d1ae
......@@ -169,6 +169,7 @@ typedef intintobjargproc ssizessizeobjargproc;
#include <unicode/ucasemap.h>
#include <unicode/udata.h>
#include <unicode/ubidi.h>
#include <unicode/uclean.h>
#define VERSION_HEX(major, minor, patch) \
(((major) << 24) | ((minor) << 16) | ((patch) << 8))
......
......@@ -248,6 +248,7 @@ static PyObject *t_resourcebundle_getIntVector(t_resourcebundle *self);
static PyObject *t_resourcebundle_getLocale(t_resourcebundle *self,
PyObject *args);
static PyObject *t_resourcebundle_resetICU(PyTypeObject *type);
#ifndef PYPY_VERSION
static PyObject *t_resourcebundle_setAppData(PyTypeObject *type,
PyObject *args);
......@@ -272,6 +273,7 @@ static PyMethodDef t_resourcebundle_methods[] = {
DECLARE_METHOD(t_resourcebundle, getBinary, METH_NOARGS),
DECLARE_METHOD(t_resourcebundle, getIntVector, METH_NOARGS),
DECLARE_METHOD(t_resourcebundle, getLocale, METH_VARARGS),
DECLARE_METHOD(t_resourcebundle, resetICU, METH_CLASS | METH_NOARGS),
#ifndef PYPY_VERSION
DECLARE_METHOD(t_resourcebundle, setAppData, METH_CLASS | METH_VARARGS),
#endif
......@@ -1572,6 +1574,17 @@ static PyObject *t_resourcebundle_getLocale(t_resourcebundle *self,
return PyErr_SetArgsError((PyObject *) self, "getLocale", args);
}
// Use this with care, see docs for u_cleanup() and u_init() in uclean.h or at
// https://unicode-org.github.io/icu-docs/apidoc/dev/icu4c/uclean_8h.html
static PyObject *t_resourcebundle_resetICU(PyTypeObject *type)
{
u_cleanup();
STATUS_CALL(u_init(&status));
Py_RETURN_NONE;
}
#ifndef PYPY_VERSION
#if defined(_MSC_VER) || defined(__WIN32)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment