diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-01 01:15:00 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-01 01:15:00 (GMT) |
commit | db88ae5d666723d90c9b681fe874aa0a8fb4b04a (patch) | |
tree | 283491fcdf6dbd81c89b20cfae938bd55c002b32 /Objects | |
parent | 59bb0e077fa8f6942bdb0ca44ac462a58379d375 (diff) | |
download | cpython-db88ae5d666723d90c9b681fe874aa0a8fb4b04a.zip cpython-db88ae5d666723d90c9b681fe874aa0a8fb4b04a.tar.gz cpython-db88ae5d666723d90c9b681fe874aa0a8fb4b04a.tar.bz2 |
PyObject_Repr() ensures that the result is a ready Unicode string
And PyObject_Str() and PyObject_Repr() don't make strings ready in debug
mode to ensure that the caller makes the string ready before using it.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/object.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c index 00f1716..eea5531 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -385,6 +385,10 @@ PyObject_Repr(PyObject *v) Py_DECREF(res); return NULL; } +#ifndef Py_DEBUG + if (PyUnicode_READY(res) < 0) + return NULL; +#endif return res; } @@ -403,8 +407,10 @@ PyObject_Str(PyObject *v) if (v == NULL) return PyUnicode_FromString("<NULL>"); if (PyUnicode_CheckExact(v)) { +#ifndef Py_DEBUG if (PyUnicode_READY(v) < 0) return NULL; +#endif Py_INCREF(v); return v; } @@ -426,8 +432,10 @@ PyObject_Str(PyObject *v) Py_DECREF(res); return NULL; } +#ifndef Py_DEBUG if (PyUnicode_READY(res) < 0) return NULL; +#endif assert(_PyUnicode_CheckConsistency(res, 1)); return res; } |