diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-04-28 11:08:27 -0400 |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-04-28 11:08:27 -0400 |
commit | ae3dbb9b279701ee8378123ac74f2f5d59b2c377 (patch) | |
tree | 30e8b2105a17dc98a78e98a0730d3235557a8c9c /Python/formatter_unicode.c | |
parent | 62e6455f78c85d5fa1c983a499ab089bd22e2c4e (diff) | |
parent | 519ad453b3624294a5c7664208d3a4f8ac353cdc (diff) | |
download | cpython-ae3dbb9b279701ee8378123ac74f2f5d59b2c377.tar.gz |
Merge #7152: Clarify that ProxyHandler is added only if proxy settings are detected.
Behavior confirmation and initial patch by Jessica McKellar.
Diffstat (limited to 'Python/formatter_unicode.c')
-rw-r--r-- | Python/formatter_unicode.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index 17eb9789e0..009bc5fd03 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -757,7 +757,8 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format, goto done; } - if (format->width == -1 && format->precision == -1) { + if ((format->width == -1 || format->width <= len) + && (format->precision == -1 || format->precision >= len)) { /* Fast path */ return _PyUnicodeWriter_WriteStr(writer, value); } @@ -770,9 +771,13 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format, calc_padding(len, format->width, format->align, &lpad, &rpad, &total); - maxchar = _PyUnicode_FindMaxChar(value, 0, len); + maxchar = writer->maxchar; if (lpad != 0 || rpad != 0) maxchar = Py_MAX(maxchar, format->fill_char); + if (PyUnicode_MAX_CHAR_VALUE(value) > maxchar) { + Py_UCS4 valmaxchar = _PyUnicode_FindMaxChar(value, 0, len); + maxchar = Py_MAX(maxchar, valmaxchar); + } /* allocate the resulting string */ if (_PyUnicodeWriter_Prepare(writer, total, maxchar) == -1) |