Mercurial > cpython-lru_cache-weakref
diff Objects/moduleobject.c @ 66821:738eaeed0b1a
Updated UCD version and unicode.org links to Unicode 6.0.0
| author | Alexander Belopolsky <alexander.belopolsky@gmail.com> |
|---|---|
| date | Fri, 10 Dec 2010 18:11:24 +0000 |
| parents | 62b61abd02b8 |
| children | 4f849720bf41 |
line wrap: on
line diff
--- a/Objects/moduleobject.c Fri Dec 10 17:45:13 2010 +0000 +++ b/Objects/moduleobject.c Fri Dec 10 18:11:24 2010 +0000 @@ -168,8 +168,8 @@ return d; } -const char * -PyModule_GetName(PyObject *m) +PyObject * +PyModule_GetNameObject(PyObject *m) { PyObject *d; PyObject *nameobj; @@ -185,7 +185,21 @@ 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*
