Skip to content

Commit b6b0e29

Browse files
committed
Clarify which part is wrong
1 parent af8045f commit b6b0e29

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Objects/unicode_formatter.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,17 @@ invalid_thousands_separator_type(char separator, Py_UCS4 presentation_type)
287287
separator, (int)presentation_type);
288288
}
289289

290+
static void
291+
invalid_fraction_separator_type(char separator, Py_UCS4 presentation_type)
292+
{
293+
assert(separator == ',' || separator == '_');
294+
/* presentation_type has been checked before thousands separator. */
295+
assert(presentation_type >= 32 && presentation_type < 127);
296+
PyErr_Format(PyExc_ValueError,
297+
"Cannot specify '%c' in fractional part with type code '%c'",
298+
separator, (int)presentation_type);
299+
}
300+
290301
static void
291302
invalid_comma_and_underscore(void)
292303
{
@@ -638,8 +649,8 @@ parse_internal_render_format_spec(PyObject *obj,
638649
case '\0':
639650
break;
640651
default:
641-
invalid_thousands_separator_type(format->frac_thousands_separator,
642-
format->type);
652+
invalid_fraction_separator_type(format->frac_thousands_separator,
653+
format->type);
643654
return 0;
644655
}
645656
}

0 commit comments

Comments
 (0)