diff options
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c index 704ffc1..718dddf 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -250,10 +250,16 @@ PyObject_Str(PyObject *v) if (v == NULL) return PyString_FromString("<NULL>"); - if (PyString_Check(v)) { + if (PyString_CheckExact(v)) { Py_INCREF(v); return v; } + if (PyString_Check(v)) { + /* For a string subtype that's not a string, return a true + string with the same string data. */ + PyStringObject *s = (PyStringObject *)v; + return PyString_FromStringAndSize(s->ob_sval, s->ob_size); + } if (v->ob_type->tp_str == NULL) return PyObject_Repr(v); |