summaryrefslogtreecommitdiff
path: root/Python/formatter_unicode.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-06 01:45:57 +0200
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-06 01:45:57 +0200
commit7cba64b1d6dd00da0c98fceaac11e3fc7086c852 (patch)
treeb42384cb742feb409d9ea1e9e1010ad5df6690c4 /Python/formatter_unicode.c
parentbccc61d6b36c0b7223f7f066424c90ad23c82b30 (diff)
downloadcpython-7cba64b1d6dd00da0c98fceaac11e3fc7086c852.tar.gz
Don't check for the maximum character when copying from unicodeobject.c
* Create copy_characters() function which doesn't check for the maximum character in release mode * _PyUnicode_CheckConsistency() is no more static to be able to use it in _PyUnicode_FormatAdvanced() (in formatter_unicode.c) * _PyUnicode_CheckConsistency() checks the string hash
Diffstat (limited to 'Python/formatter_unicode.c')
-rw-r--r--Python/formatter_unicode.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c
index c989d83654..a389734390 100644
--- a/Python/formatter_unicode.c
+++ b/Python/formatter_unicode.c
@@ -1284,33 +1284,31 @@ _PyUnicode_FormatAdvanced(PyObject *obj,
Py_ssize_t start, Py_ssize_t end)
{
InternalFormatSpec format;
- PyObject *result = NULL;
+ PyObject *result;
/* check for the special case of zero length format spec, make
it equivalent to str(obj) */
- if (start == end) {
- result = PyObject_Str(obj);
- goto done;
- }
+ if (start == end)
+ return PyObject_Str(obj);
/* parse the format_spec */
if (!parse_internal_render_format_spec(format_spec, start, end,
&format, 's', '<'))
- goto done;
+ return NULL;
/* type conversion? */
switch (format.type) {
case 's':
/* no type conversion needed, already a string. do the formatting */
result = format_string_internal(obj, &format);
+ if (result != NULL)
+ assert(_PyUnicode_CheckConsistency(result, 1));
break;
default:
/* unknown */
unknown_presentation_type(format.type, obj->ob_type->tp_name);
- goto done;
+ result = NULL;
}
-
-done:
return result;
}