@@ -156,8 +156,9 @@ parse_internal_render_format_spec(PyObject *format_spec,
156
156
157
157
Py_ssize_t consumed ;
158
158
int align_specified = 0 ;
159
+ int fill_char_specified = 0 ;
159
160
160
- format -> fill_char = '\0 ' ;
161
+ format -> fill_char = ' ' ;
161
162
format -> align = default_align ;
162
163
format -> alternate = 0 ;
163
164
format -> sign = '\0' ;
@@ -171,6 +172,7 @@ parse_internal_render_format_spec(PyObject *format_spec,
171
172
if (end - pos >= 2 && is_alignment_token (READ_spec (pos + 1 ))) {
172
173
format -> align = READ_spec (pos + 1 );
173
174
format -> fill_char = READ_spec (pos );
175
+ fill_char_specified = 1 ;
174
176
align_specified = 1 ;
175
177
pos += 2 ;
176
178
}
@@ -194,7 +196,7 @@ parse_internal_render_format_spec(PyObject *format_spec,
194
196
}
195
197
196
198
/* The special case for 0-padding (backwards compat) */
197
- if (format -> fill_char == '\0' && end - pos >= 1 && READ_spec (pos ) == '0' ) {
199
+ if (! fill_char_specified && end - pos >= 1 && READ_spec (pos ) == '0' ) {
198
200
format -> fill_char = '0' ;
199
201
if (!align_specified ) {
200
202
format -> align = '=' ;
@@ -784,9 +786,7 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format,
784
786
goto done ;
785
787
786
788
/* Write into that space. First the padding. */
787
- result = fill_padding (writer , len ,
788
- format -> fill_char == '\0' ?' ' :format -> fill_char ,
789
- lpad , rpad );
789
+ result = fill_padding (writer , len , format -> fill_char , lpad , rpad );
790
790
if (result == -1 )
791
791
goto done ;
792
792
@@ -956,8 +956,7 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format,
956
956
/* Populate the memory. */
957
957
result = fill_number (writer , & spec ,
958
958
tmp , inumeric_chars , inumeric_chars + n_digits ,
959
- tmp , prefix ,
960
- format -> fill_char == '\0' ? ' ' : format -> fill_char ,
959
+ tmp , prefix , format -> fill_char ,
961
960
& locale , format -> type == 'X' );
962
961
963
962
done :
@@ -1104,8 +1103,7 @@ format_float_internal(PyObject *value,
1104
1103
/* Populate the memory. */
1105
1104
result = fill_number (writer , & spec ,
1106
1105
unicode_tmp , index , index + n_digits ,
1107
- NULL , 0 ,
1108
- format -> fill_char == '\0' ? ' ' : format -> fill_char ,
1106
+ NULL , 0 , format -> fill_char ,
1109
1107
& locale , 0 );
1110
1108
1111
1109
done :
@@ -1311,8 +1309,7 @@ format_complex_internal(PyObject *value,
1311
1309
/* Populate the memory. First, the padding. */
1312
1310
result = fill_padding (writer ,
1313
1311
n_re_total + n_im_total + 1 + add_parens * 2 ,
1314
- format -> fill_char == '\0' ? ' ' : format -> fill_char ,
1315
- lpad , rpad );
1312
+ format -> fill_char , lpad , rpad );
1316
1313
if (result == -1 )
1317
1314
goto done ;
1318
1315
0 commit comments