[Python-Dev] Minidom and Unicode
M.-A. Lemburg
mal@lemburg.com
Mon, 03 Jul 2000 10:43:59 +0200
Fredrik Lundh wrote:
>
> paul wrote:
>
> > If we want to use a hard-coded lossless encoding, we should do so in
> > repr. Rather than having us fix a dozen modules with problems like this,
> > we should fix repr once and for all.
>
> how about allowing str and repr to actually return
> unicode strings?
>
> or in other words:
>
> PyObject *res;
> res = (*v->ob_type->tp_repr)(v);
> if (res == NULL)
> return NULL;
> if (!PyString_Check(res) && !PyUnicode_Check(res)) {
> PyErr_Format(PyExc_TypeError,
> "__repr__ returned non-string (type %.200s)",
> res->ob_type->tp_name);
> Py_DECREF(res);
> return NULL;
> }
> return res;
>
> (strings are strings are strings, etc)
-1: This breaks code, since it is expected that PyObject_Str()
returns a string object.
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/