toml
toml copied to clipboard
Incorrectly parsing fractions of a second when not enough digits are given
I'm using toml 0.10.1 downloaded from PyPI on CPython 3.8.0 on Linux.
My code:
import toml
for i in range(1, 8):
v = "12:34:56." + "1234567"[:i]
print(v, toml.loads("a=" + v)['a'])
Output:
12:34:56.1 12:34:56
12:34:56.12 12:34:56
12:34:56.123 12:34:56.000123
12:34:56.1234 12:34:56.001234
12:34:56.12345 12:34:56.012345
12:34:56.123456 12:34:56.123456
12:34:56.1234567 12:34:56.123456
Expected output:
12:34:56.1 12:34:56.100000
12:34:56.12 12:34:56.120000
12:34:56.123 12:34:56.123000
12:34:56.1234 12:34:56.123400
12:34:56.12345 12:34:56.123450
12:34:56.123456 12:34:56.123456
12:34:56.1234567 12:34:56.123456
Submitted a fix that passes your example. It was throwing away 1-2 characters
There was also an incorrect parsing of the "secfrac" component into microseconds of time values. Now the expected output is achieved.