[Python-checkins] cpython: fill_number() and format_string_internal() check for PyUnicode_CopyCharacters()

victor.stinner python-checkins at python.org
Wed Sep 28 22:08:40 CEST 2011


http://hg.python.org/cpython/rev/f05c2df39ea8
changeset: 72497:f05c2df39ea8
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Wed Sep 28 21:53:49 2011 +0200
summary:
 fill_number() and format_string_internal() check for PyUnicode_CopyCharacters() failure
files:
 Python/formatter_unicode.c | 11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c
--- a/Python/formatter_unicode.c
+++ b/Python/formatter_unicode.c
@@ -566,7 +566,10 @@
 PyUnicode_WRITE(kind, data, pos++, spec->sign);
 }
 if (spec->n_prefix) {
- PyUnicode_CopyCharacters(out, pos, prefix, p_start, spec->n_prefix);
+ if (PyUnicode_CopyCharacters(out, pos,
+ prefix, p_start,
+ spec->n_prefix) < 0)
+ return -1;
 if (toupper) {
 Py_ssize_t t;
 /* XXX if the upper-case prefix is wider than the target
@@ -632,7 +635,8 @@
 }
 
 if (spec->n_remainder) {
- PyUnicode_CopyCharacters(out, pos, digits, d_pos, spec->n_remainder);
+ if (PyUnicode_CopyCharacters(out, pos, digits, d_pos, spec->n_remainder) < 0)
+ return -1;
 pos += spec->n_remainder;
 d_pos += spec->n_remainder;
 }
@@ -735,7 +739,8 @@
 lpad, rpad);
 
 /* Then the source string. */
- PyUnicode_CopyCharacters(result, pos, value, 0, len);
+ if (PyUnicode_CopyCharacters(result, pos, value, 0, len) < 0)
+ Py_CLEAR(result);
 
 done:
 return result;
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /