mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
Close #18780: %-formatting now prints value for int subclasses with %d, %i, and %u codes.
This commit is contained in:
parent
08548f4a75
commit
fb13721b1b
3 changed files with 53 additions and 5 deletions
|
@ -13566,11 +13566,9 @@ formatlong(PyObject *val, struct unicode_format_arg_t *arg)
|
|||
case 'd':
|
||||
case 'i':
|
||||
case 'u':
|
||||
/* Special-case boolean: we want 0/1 */
|
||||
if (PyBool_Check(val))
|
||||
result = PyNumber_ToBase(val, 10);
|
||||
else
|
||||
result = Py_TYPE(val)->tp_str(val);
|
||||
/* int and int subclasses should print numerically when a numeric */
|
||||
/* format code is used (see issue18780) */
|
||||
result = PyNumber_ToBase(val, 10);
|
||||
break;
|
||||
case 'o':
|
||||
numnondigits = 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue