Skip to main content

numeric_literal_from_str

Function numeric_literal_from_str 

Source
pub fn numeric_literal_from_str(s: &Py<PyStr>) -> Cow<'_, str>
Expand description

Normalize a str for the byte-oriented numeric parsers: Unicode decimal digits and whitespace fold to their ASCII equivalents, the way CPython runs every numeric constructor’s string argument through _PyUnicode_TransformDecimalAndSpaceToASCII first.

int, float and complex share this step and nothing else — only int takes a base, and only int and float accept bytes-like input, so each keeps its own entry point around this one.

A string holding surrogates can never be a valid literal, so it folds to an empty — and therefore invalid — one.