Throw error for invalid characters for number base#22365
Conversation
This is about the situation where a character is not within the
specified number base. E.g. only 0-9, a-f are allowed for hexadecimal,
so what should `hexdec('z')` do?
In the past, such characters were silently ignored. Since PHP 7.4 a
deprecation notice would be generated. This commit changes that to a
ValueError.
Earlier RFC:
https://wiki.php.net/rfc/base_convert_improvements
|
Hi @Sjord. My main concern is process about your PR is effectively phase 2 of the 2018 base_convert_improvements RFC (the 8.0 exception that never shipped), It also overlaps your own precision-loss thread; both touch _php_math_basetozval, better designed together. |
In bindec, octdec, hexdec, and base_convert, the string to convert is the first argument, so we can throw a ValueError specific to that argument when it contains invalid characters.
|
I also mailed the internals mailing list:
|
This is about the situation where a character is not within the specified number base. E.g. only 0-9, a-f are allowed for hexadecimal, so what should
hexdec('z')do?In the past, such characters were silently ignored. Since PHP 7.4 a deprecation notice would be generated. This commit changes that to a ValueError.
Earlier RFC:
https://wiki.php.net/rfc/base_convert_improvements