Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 15952:1f92d63b20f0 legacy-trunk
This patch adds a new builtin unistr() which behaves like str()
except that it always returns Unicode objects.
A new C API PyObject_Unicode() is also provided.
This closes patch #101664.
Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
| author | Marc-André Lemburg <mal@egenix.com> |
|---|---|
| date | Wed, 17 Jan 2001 17:09:53 +0000 |
| parents | 76ad2a9a3e53 |
| children | d90eeab5f9a4 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Wed Jan 17 15:59:25 2001 +0000 +++ b/Python/bltinmodule.c Wed Jan 17 17:09:53 2001 +0000 @@ -1928,6 +1928,23 @@ static PyObject * +builtin_unistr(PyObject *self, PyObject *args) +{ + PyObject *v; + + if (!PyArg_ParseTuple(args, "O:unistr", &v)) + return NULL; + return PyObject_Unicode(v); +} + +static char unistr_doc[] = +"unistr(object) -> unicode\n\ +\n\ +Return a nice unicode representation of the object.\n\ +If the argument is a unicode, the return value is the same object."; + + +static PyObject * builtin_tuple(PyObject *self, PyObject *args) { PyObject *v; @@ -2242,6 +2259,7 @@ {"type", builtin_type, 1, type_doc}, {"unicode", builtin_unicode, 1, unicode_doc}, {"unichr", builtin_unichr, 1, unichr_doc}, + {"unistr", builtin_unistr, 1, unistr_doc}, {"vars", builtin_vars, 1, vars_doc}, {"xrange", builtin_xrange, 1, xrange_doc}, {"zip", builtin_zip, 1, zip_doc},
