From dba2deeca2c070e2dfa08649b5729208567fd414 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 28 Sep 2011 21:50:42 +0200 Subject: [PATCH] fill_number() ensures that the 'digits' string is ready --- Python/formatter_unicode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index 86385f6f7fc..52ccafa8d08 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -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)