Strip underscores for int() and float()
Fixes a parse failure on integers/floats with underscores.
While the script has no problem detecting numbers with
underscores, `_p_value` would choke right before returning
them due to the strings being passed unmodified into
`int()` and `float()`.
diff --git a/pytoml/parser.py b/pytoml/parser.py
index 7da05d1..4ddcf63 100644
--- a/pytoml/parser.py
+++ b/pytoml/parser.py
@@ -264,10 +264,11 @@
if s.consume_re(_float_re):
m = s.last().group(0)
+ r = m.replace('_','')
if '.' in m or 'e' in m or 'E' in m:
- return 'float', m, float(m), pos
+ return 'float', m, float(r), pos
else:
- return 'int', m, int(m, 10), pos
+ return 'int', m, int(r, 10), pos
if s.consume('['):
items = []