diff options
author | Fredrik Lundh <fredrik@pythonware.com> | 2001-01-20 11:15:25 (GMT) |
---|---|---|
committer | Fredrik Lundh <fredrik@pythonware.com> | 2001-01-20 11:15:25 (GMT) |
commit | f60560626ce4fadf32fcbfac5e762242f661d508 (patch) | |
tree | a65aef32bd5ee544d593c3d4608dcd2d28f7efc2 /Objects/unicodeobject.c | |
parent | ebb195b2703b25e0e2d12dcdc56c8c965caf02f7 (diff) | |
download | cpython-f60560626ce4fadf32fcbfac5e762242f661d508.zip cpython-f60560626ce4fadf32fcbfac5e762242f661d508.tar.gz cpython-f60560626ce4fadf32fcbfac5e762242f661d508.tar.bz2 |
Better error message if ucnhash cannot be found (obscure attribute
errors aren't that helpful), or doesn't contain what's expected from
it. Also tweaked the test script so it compiles even if ucnhash is
missing.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index a06c40b..585afe6 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1240,15 +1240,15 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, PyObject *mod = 0, *v = 0; mod = PyImport_ImportModule("ucnhash"); if (mod == NULL) - goto onError; + goto ucnhashError; v = PyObject_GetAttrString(mod,"Unicode_Names_CAPI"); Py_DECREF(mod); if (v == NULL) - goto onError; + goto ucnhashError; unicode_names = PyCObject_AsVoidPtr(v); Py_DECREF(v); if (unicode_names == NULL) - goto onError; + goto ucnhashError; } if (*s == '{') { @@ -1311,6 +1311,11 @@ store: goto onError; return (PyObject *)v; + ucnhashError: + PyErr_SetString(PyExc_UnicodeError, + "\\N escapes not supported (can't load ucnhash module)"); + return NULL; + onError: Py_XDECREF(v); return NULL; |