mirror of
https://github.com/python/cpython.git
synced 2025-07-16 15:55:18 +00:00
Close #14648: Compute correctly maxchar in str.format() for substrin
This commit is contained in:
parent
0b7d7c9544
commit
ece58deb9f
4 changed files with 50 additions and 6 deletions
|
@ -716,7 +716,7 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format)
|
|||
Py_ssize_t pos;
|
||||
Py_ssize_t len = PyUnicode_GET_LENGTH(value);
|
||||
PyObject *result = NULL;
|
||||
Py_UCS4 maxchar = 127;
|
||||
Py_UCS4 maxchar;
|
||||
|
||||
/* sign is not allowed on strings */
|
||||
if (format->sign != '\0') {
|
||||
|
@ -747,11 +747,9 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format)
|
|||
len = format->precision;
|
||||
}
|
||||
|
||||
if (len)
|
||||
maxchar = PyUnicode_MAX_CHAR_VALUE(value);
|
||||
|
||||
calc_padding(len, format->width, format->align, &lpad, &rpad, &total);
|
||||
|
||||
maxchar = _PyUnicode_FindMaxChar(value, 0, len);
|
||||
if (lpad != 0 || rpad != 0)
|
||||
maxchar = Py_MAX(maxchar, format->fill_char);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue