Make the Rational constructor accept '3.' and '.2' as well as '3.2'.
diff --git a/Lib/rational.py b/Lib/rational.py
index bc2259b..c76cba3 100755
--- a/Lib/rational.py
+++ b/Lib/rational.py
@@ -25,9 +25,18 @@
return a
-_RATIONAL_FORMAT = re.compile(
- r'^\s*(?P<sign>[-+]?)(?P<num>\d+)'
- r'(?:/(?P<denom>\d+)|\.(?P<decimal>\d+))?\s*$')
+_RATIONAL_FORMAT = re.compile(r"""
+ \A\s* # optional whitespace at the start, then
+ (?P<sign>[-+]?) # an optional sign, then
+ (?=\d|\.\d) # lookahead for digit or .digit
+ (?P<num>\d*) # numerator (possibly empty)
+ (?: # followed by an optional
+ /(?P<denom>\d+) # / and denominator
+ | # or
+ \.(?P<decimal>\d*) # decimal point and fractional part
+ )?
+ \s*\Z # and optional whitespace to finish
+""", re.VERBOSE)
class Rational(RationalAbc):