diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2008-07-02 09:37:01 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2008-07-02 09:37:01 (GMT) |
commit | 70c3289085d08d97edbfaa626efc2d2c2ac21859 (patch) | |
tree | 4a60e0d0005acbc8ea36dea5e408aa6d43b8d2a7 /Lib/decimal.py | |
parent | 8bb8fa5dd679d1f4086fac4d3181f0985c14006d (diff) | |
download | cpython-70c3289085d08d97edbfaa626efc2d2c2ac21859.zip cpython-70c3289085d08d97edbfaa626efc2d2c2ac21859.tar.gz cpython-70c3289085d08d97edbfaa626efc2d2c2ac21859.tar.bz2 |
Replace occurrences of '\d' with '[0-9]' in Decimal regex, to make sure
that the behaviour of Decimal doesn't change if/when re.UNICODE becomes
assumed in Python 3.0.
Also add a check that alternative Unicode digits (e.g. u'\N{FULLWIDTH
DIGIT ONE}') are *not* accepted in a numeric string.
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r-- | Lib/decimal.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 940a9d2..c94e1be 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -5337,20 +5337,20 @@ ExtendedContext = Context( # other meaning for \d than the numbers [0-9]. import re -_parser = re.compile(r""" # A numeric string consists of: +_parser = re.compile(r""" # A numeric string consists of: # \s* - (?P<sign>[-+])? # an optional sign, followed by either... + (?P<sign>[-+])? # an optional sign, followed by either... ( - (?=\d|\.\d) # ...a number (with at least one digit) - (?P<int>\d*) # consisting of a (possibly empty) integer part - (\.(?P<frac>\d*))? # followed by an optional fractional part - (E(?P<exp>[-+]?\d+))? # followed by an optional exponent, or... + (?=[0-9]|\.[0-9]) # ...a number (with at least one digit) + (?P<int>[0-9]*) # having a (possibly empty) integer part + (\.(?P<frac>[0-9]*))? # followed by an optional fractional part + (E(?P<exp>[-+]?[0-9]+))? # followed by an optional exponent, or... | - Inf(inity)? # ...an infinity, or... + Inf(inity)? # ...an infinity, or... | - (?P<signal>s)? # ...an (optionally signaling) - NaN # NaN - (?P<diag>\d*) # with (possibly empty) diagnostic information. + (?P<signal>s)? # ...an (optionally signaling) + NaN # NaN + (?P<diag>[0-9]*) # with (possibly empty) diagnostic info. ) # \s* \Z |