summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2000-07-07 13:48:25 +0000
committerMarc-André Lemburg <mal@egenix.com>2000-07-07 13:48:25 +0000
commit18885f36eb40bfa315c88e67fe6e2b9a172a6b9b (patch)
treeabd95c087e0168dc6ea9301b42f5c71de497a52f /Python
parent143ae5928f037536a44b09bf07c5ed84836b8be9 (diff)
downloadcpython-18885f36eb40bfa315c88e67fe6e2b9a172a6b9b.tar.gz
Fixed unicode() to use the new API PyUnicode_FromEncodedObject().
This adds support for instance to the constructor (instances have to define __str__ and can return Unicode objects via that hook; string return values are decoded into Unicode using the current default encoding).
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 82867e0f43..8e2720b93c 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -155,20 +155,7 @@ builtin_unicode(self, args)
if ( !PyArg_ParseTuple(args, "O|ss:unicode", &v, &encoding, &errors) )
return NULL;
- /* Special case: Unicode will stay Unicode */
- if (PyUnicode_Check(v)) {
- if (encoding) {
- PyErr_SetString(PyExc_TypeError,
- "unicode() does not support decoding of Unicode objects");
- return NULL;
- }
- Py_INCREF(v);
- return v;
- }
- /* Read raw data and decode it */
- if (PyObject_AsReadBuffer(v, &buffer, &len))
- return NULL;
- return PyUnicode_Decode((const char *)buffer, len, encoding, errors);
+ return PyUnicode_FromEncodedObject(v, encoding, errors);
}
static char unicode_doc[] =