Fix bug where (float)"infi" did not produce Infinity.

This commit is contained in:
Sei Lisa 2015-02-28 17:34:26 +01:00
parent 42ac090f03
commit 1440f7811e

View file

@ -32,6 +32,9 @@ from base64 import b64encode, b64decode
# The lookahead (?!i) is essential for parsing them that way without extra code.
# Note that '|' in REs is order-sensitive.
float_re = re.compile(ur'^\s*[+-]?(?:0(x)(?:[0-9a-f]+(?:\.[0-9a-f]*)?|\.[0-9a-f]+)(?:p[+-]?[0-9]+)?'
ur'|(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:e[+-]?[0-9]+)?|inf|nan)',
re.I)
vfloat_re = re.compile(ur'^\s*[+-]?(?:0(x)(?:[0-9a-f]+(?:\.[0-9a-f]*)?|\.[0-9a-f]+)(?:p[+-]?[0-9]+)?'
ur'|(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:e[+-]?[0-9]+)?|infinity|inf(?!i)|nan)',
re.I)
@ -329,7 +332,7 @@ def InternalTypecast(val, out, InList, f32):
return Z
val = val[1:]
for _ in range(dim):
match = float_re.match(val)
match = vfloat_re.match(val)
if match is None:
return Z
if match.group(1):