summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-11-20 18:48:36 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-11-20 18:48:36 (GMT)
commit4ead7c7be8089de7cab5db7d2a75e6bec5b55f10 (patch)
tree7917a647fd0e2bf4e29c6ce5f0624de1f52b0c55 /Objects/object.c
parent2b979bfa3c27636fe298b7c5d8f17354bd2b566c (diff)
downloadcpython-4ead7c7be8089de7cab5db7d2a75e6bec5b55f10.zip
cpython-4ead7c7be8089de7cab5db7d2a75e6bec5b55f10.tar.gz
cpython-4ead7c7be8089de7cab5db7d2a75e6bec5b55f10.tar.bz2
PyObject_Str() ensures that the result string is ready
and check the string consistency. _PyUnicode_CheckConsistency() doesn't check the hash anymore. It should be possible to call this function even if hash(str) was already called.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 51188b7..25e64e1 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -403,6 +403,8 @@ PyObject_Str(PyObject *v)
if (v == NULL)
return PyUnicode_FromString("<NULL>");
if (PyUnicode_CheckExact(v)) {
+ if (PyUnicode_READY(v) < 0)
+ return NULL;
Py_INCREF(v);
return v;
}
@@ -424,6 +426,9 @@ PyObject_Str(PyObject *v)
Py_DECREF(res);
return NULL;
}
+ if (PyUnicode_READY(res) < 0)
+ return NULL;
+ assert(_PyUnicode_CheckConsistency(res, 1));
return res;
}