From fc55789cae2db09fe190989943b112fbdc0f5423 Mon Sep 17 00:00:00 2001 From: Alexander Belopolsky Date: Fri, 10 Dec 2010 18:11:24 +0000 Subject: Updated UCD version and unicode.org links to Unicode 6.0.0 --- Doc/library/unicodedata.rst | 17 +++++++++-------- Modules/_lsprof.c | 34 ++++++++++++---------------------- Objects/moduleobject.c | 20 +++++++++++++++++--- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/Doc/library/unicodedata.rst b/Doc/library/unicodedata.rst index bbbd5d9..bcb3da3 100644 --- a/Doc/library/unicodedata.rst +++ b/Doc/library/unicodedata.rst @@ -13,14 +13,15 @@ single: character pair: Unicode; database -This module provides access to the Unicode Character Database which defines -character properties for all Unicode characters. The data in this database is -based on the :file:`UnicodeData.txt` file version 5.2.0 which is publicly -available from ftp://ftp.unicode.org/. - -The module uses the same names and symbols as defined by the UnicodeData File -Format 5.2.0 (see http://www.unicode.org/reports/tr44/tr44-4.html). -It defines the following functions: +This module provides access to the Unicode Character Database (UCD) which +defines character properties for all Unicode characters. The data contained in +this database is compiled from the `UCD version 6.0.0 +`_. + +The module uses the same names and symbols as defined by Unicode +Standard Annex #44, `"Unicode Character Database" +`_. It defines the +following functions: .. function:: lookup(name) diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index cc412bf..199c42b 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -176,31 +176,21 @@ normalizeUserObj(PyObject *obj) if (fn->m_self == NULL) { /* built-in function: look up the module name */ PyObject *mod = fn->m_module; - const char *modname; - if (mod && PyUnicode_Check(mod)) { - /* XXX: The following will truncate module names with embedded - * null-characters. It is unlikely that this can happen in - * practice and the concequences are not serious enough to - * introduce extra checks here. - */ - modname = _PyUnicode_AsString(mod); - if (modname == NULL) { - modname = ""; - PyErr_Clear(); + PyObject *modname; + if (mod != NULL) { + if (PyUnicode_Check(mod)) { + modname = mod; + Py_INCREF(modname); } - } - else if (mod && PyModule_Check(mod)) { - modname = PyModule_GetName(mod); - if (modname == NULL) { - PyErr_Clear(); - modname = "builtins"; + else if (PyModule_Check(mod)) { + modname = PyModule_GetNameObject(mod); + if (modname == NULL) + PyErr_Clear(); } } - else { - modname = "builtins"; - } - if (strcmp(modname, "builtins") != 0) - return PyUnicode_FromFormat("<%s.%s>", + if (modname != NULL && + PyUnicode_CompareWithASCIIString(modname, "builtins") != 0) + return PyUnicode_FromFormat("<%U.%s>", modname, fn->m_ml->ml_name); else diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 2c095a0..8b22b7d 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -168,8 +168,8 @@ PyModule_GetDict(PyObject *m) return d; } -const char * -PyModule_GetName(PyObject *m) +PyObject * +PyModule_GetNameObject(PyObject *m) { PyObject *d; PyObject *nameobj; @@ -185,7 +185,21 @@ PyModule_GetName(PyObject *m) PyErr_SetString(PyExc_SystemError, "nameless module"); return NULL; } - return _PyUnicode_AsString(nameobj); + Py_INCREF(nameobj); + return nameobj; +} + +const char * +PyModule_GetName(PyObject *m) +{ + PyObject *nameobj; + char *utf8; + nameobj = PyModule_GetNameObject(m); + if (nameobj == NULL) + return NULL; + utf8 = _PyUnicode_AsString(nameobj); + Py_DECREF(nameobj); + return utf8; } PyObject* -- cgit v0.12