aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-04-23 23:36:38 +0200
committerVictor Stinner <victor.stinner@gmail.com>2012-04-23 23:36:38 +0200
commitece58deb9fd72674b84ef7a01c944b5eed6b37a1 (patch)
tree040cbeefd99fc35b73a9a9505efb58a61177eda4 /Python/formatter_unicode.c
parentMerge #14640: Fix typos/syntax in pyporting.rst. (diff)
downloadcpython-ece58deb9fd72674b84ef7a01c944b5eed6b37a1.tar.gz
cpython-ece58deb9fd72674b84ef7a01c944b5eed6b37a1.tar.bz2
cpython-ece58deb9fd72674b84ef7a01c944b5eed6b37a1.zip
Close #14648: Compute correctly maxchar in str.format() for substrin
Diffstat (limited to 'Python/formatter_unicode.c')
-rw-r--r--Python/formatter_unicode.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c
index 5e5b19f7fea..e1c00df9e6b 100644
--- a/Python/formatter_unicode.c
+++ b/Python/formatter_unicode.c
@@ -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);