[Python-Dev] Minidom and Unicode

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Sat, 1 Jul 2000 21:11:34 +0200


paul wrote:
=20
> 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.
=20
how about allowing str and repr to actually return
unicode strings?

or in other words:

        PyObject *res;
        res =3D (*v->ob_type->tp_repr)(v);
        if (res =3D=3D 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)

</F>