Allow whitespace around a slash in fraction string inputs (GH-96496)

This commit is contained in:
Raymond Hettinger 2022-09-02 11:10:58 -05:00 committed by GitHub
parent 91f40f3f78
commit 656167db81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 4 deletions

View file

@ -26,7 +26,7 @@ _RATIONAL_FORMAT = re.compile(r"""
(?=\d|\.\d) # lookahead for digit or .digit
(?P<num>\d*|\d+(_\d+)*) # numerator (possibly empty)
(?: # followed by
(?:/(?P<denom>\d+(_\d+)*))? # an optional denominator
(?:\s*/\s*(?P<denom>\d+(_\d+)*))? # an optional denominator
| # or
(?:\.(?P<decimal>d*|\d+(_\d+)*))? # an optional fractional part
(?:E(?P<exp>[-+]?\d+(_\d+)*))? # and optional exponent