@@ -559,8 +559,9 @@ fill_number(PyObject *out, Py_ssize_t pos, const NumberFieldWidths *spec,
559559 Py_ssize_t t ;
560560 for (t = 0 ; t < spec -> n_prefix ; t ++ ) {
561561 Py_UCS4 c = PyUnicode_READ (kind , data , pos + t );
562+ c = Py_TOUPPER (c );
562563 assert (c <= 127 );
563- PyUnicode_WRITE (kind , data , pos + t , Py_TOUPPER ( c ) );
564+ PyUnicode_WRITE (kind , data , pos + t , c );
564565 }
565566 }
566567 pos += spec -> n_prefix ;
@@ -603,11 +604,12 @@ fill_number(PyObject *out, Py_ssize_t pos, const NumberFieldWidths *spec,
603604 Py_ssize_t t ;
604605 for (t = 0 ; t < spec -> n_grouped_digits ; t ++ ) {
605606 Py_UCS4 c = PyUnicode_READ (kind , data , pos + t );
607+ c = Py_TOUPPER (c );
606608 if (c > 127 ) {
607609 PyErr_SetString (PyExc_SystemError , "non-ascii grouped digit" );
608610 return -1 ;
609611 }
610- PyUnicode_WRITE (kind , data , pos + t , Py_TOUPPER ( c ) );
612+ PyUnicode_WRITE (kind , data , pos + t , c );
611613 }
612614 }
613615 pos += spec -> n_grouped_digits ;
@@ -733,6 +735,7 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format)
733735 Py_CLEAR (result );
734736
735737done :
738+ assert (!result || _PyUnicode_CheckConsistency (result , 1 ));
736739 return result ;
737740}
738741
@@ -759,7 +762,7 @@ format_int_or_long_internal(PyObject *value, const InternalFormatSpec *format,
759762 produces non-digits */
760763 Py_ssize_t n_prefix = 0 ; /* Count of prefix chars, (e.g., '0x') */
761764 Py_ssize_t n_total ;
762- Py_ssize_t prefix ;
765+ Py_ssize_t prefix = 0 ;
763766 NumberFieldWidths spec ;
764767 long x ;
765768 int err ;
@@ -894,6 +897,7 @@ format_int_or_long_internal(PyObject *value, const InternalFormatSpec *format,
894897
895898done :
896899 Py_XDECREF (tmp );
900+ assert (!result || _PyUnicode_CheckConsistency (result , 1 ));
897901 return result ;
898902}
899903
@@ -1036,6 +1040,7 @@ format_float_internal(PyObject *value,
10361040done :
10371041 PyMem_Free (buf );
10381042 Py_DECREF (unicode_tmp );
1043+ assert (!result || _PyUnicode_CheckConsistency (result , 1 ));
10391044 return result ;
10401045}
10411046
@@ -1270,6 +1275,7 @@ format_complex_internal(PyObject *value,
12701275 PyMem_Free (im_buf );
12711276 Py_XDECREF (re_unicode_tmp );
12721277 Py_XDECREF (im_unicode_tmp );
1278+ assert (!result || _PyUnicode_CheckConsistency (result , 1 ));
12731279 return result ;
12741280}
12751281
0 commit comments