diff --git a/src/calibre/utils/icu.c b/src/calibre/utils/icu.c index 8372669258..f306618577 100644 --- a/src/calibre/utils/icu.c +++ b/src/calibre/utils/icu.c @@ -273,6 +273,8 @@ icu_Collator_contractions(icu_Collator *self, PyObject *args, PyObject *kwargs) } // }}} // Collator.span_contractions {{{ +#ifndef __APPLE__ +// uset_span is not available in the version of ICU on Apple's idiotic OS static PyObject * icu_Collator_span_contractions(icu_Collator *self, PyObject *args, PyObject *kwargs) { int span_type; @@ -302,8 +304,9 @@ icu_Collator_span_contractions(icu_Collator *self, PyObject *args, PyObject *kwa ret = uset_span(self->contractions, s, slen, span_type); free(s); free(buf); return Py_BuildValue("i", ret); -} // }}} - +} +#endif +// }}} static PyObject* icu_Collator_clone(icu_Collator *self, PyObject *args, PyObject *kwargs); @@ -325,9 +328,11 @@ static PyMethodDef icu_Collator_methods[] = { "contractions() -> returns the contractions defined for this collator." }, +#ifndef __APPLE__ {"span_contractions", (PyCFunction)icu_Collator_span_contractions, METH_VARARGS, "span_contractions(src, span_condition) -> returns the length of the initial substring according to span_condition in the set of contractions for this collator. Returns 0 if src does not fit the span_condition. The span_condition can be one of USET_SPAN_NOT_CONTAINED, USET_SPAN_CONTAINED, USET_SPAN_SIMPLE." }, +#endif {"clone", (PyCFunction)icu_Collator_clone, METH_VARARGS, "clone() -> returns a clone of this collator." @@ -609,7 +614,10 @@ initicu(void) UErrorCode status = U_ZERO_ERROR; u_init(&status); - + if (U_FAILURE(status)) { + PyErr_SetString(PyExc_RuntimeError, u_errorName(status)); + return; + } if (PyType_Ready(&icu_CollatorType) < 0) return; diff --git a/src/calibre/utils/icu.py b/src/calibre/utils/icu.py index c4778fcb24..b179ac7b46 100644 --- a/src/calibre/utils/icu.py +++ b/src/calibre/utils/icu.py @@ -33,7 +33,7 @@ def load_icu(): if _icu is None: _icu = plugins['icu'][0] if _icu is None: - print plugins['icu'][1] + print 'Loading ICU failed with: ', plugins['icu'][1] else: if not getattr(_icu, 'ok', False): print 'icu not ok'