]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fill_number() ensures that the 'digits' string is ready
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 28 Sep 2011 19:50:42 +0000 (21:50 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 28 Sep 2011 19:50:42 +0000 (21:50 +0200)
Python/formatter_unicode.c

index 86385f6f7fc6eb2a73481f149a0e3565734e7569..52ccafa8d085021310a25524c88fc52c17a0f62d 100644 (file)
@@ -587,7 +587,10 @@ fill_number(PyObject *out, Py_ssize_t pos, const NumberFieldWidths *spec,
     /* Only for type 'c' special case, it has no digits. */
     if (spec->n_digits != 0) {
         /* Fill the digits with InsertThousandsGrouping. */
-        char *pdigits = PyUnicode_DATA(digits);
+        char *pdigits;
+        if (PyUnicode_READY(digits))
+            return -1;
+        pdigits = PyUnicode_DATA(digits);
         if (PyUnicode_KIND(digits) < kind) {
             pdigits = _PyUnicode_AsKind(digits, kind);
             if (pdigits == NULL)