-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The DosDateTime.deserialize_time function produce ValueError: second must be in 0..59 #34
Comments
Interesting! According to the FAT specification having a second value >29 (in this case: 30) is invalid: Do you mind sharing what created the file and/or the filesystem? Maybe even an example filesystem image? At least in PyFatFS there's a boundary check in place that verifies the seconds range: >>> from pyfatfs.DosDateTime import DosDateTime
>>> DosDateTime(1980, 1, 1, 0, 0, 60)
Traceback (most recent call last):
File "/app/extra/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode
coro = func()
^^^^^^
File "<input>", line 1, in <module>
ValueError: second must be in 0..59 Serialization of the boundary is part of the test suite and seems to work as intended: >>> from pyfatfs.DosDateTime import DosDateTime
>>> hex(DosDateTime(1980, 1, 1, 0, 0, 58).serialize_time())
'0x1d'
>>> hex(DosDateTime(1980, 1, 1, 0, 0, 59).serialize_time())
'0x1d' |
It was a turbidity meter (Hach TL2350) and we believe that there is actually an issue with the instrument with regard to how it is writing invalid timestamps. We worked around it by handling the invalid value to force it to return 0 rather than triggering the exception. |
In case an invalid timestamp is encountered, an exception is thrown instead of gracefully handling the invalid timestamp. This particular malformed time was produced by a Hach TL2350 turbidity meter, producing a seconds value of 60 at the end of a minute (e.g., 0x1E). Date deserialization already properly handles this with a fallback date of 1980-01-01; similarly fall back to 00:00:00 in case of invalid timestamps.
In case an invalid timestamp is encountered, an exception is thrown instead of gracefully handling the invalid timestamp. This particular malformed time was produced by a Hach TL2350 turbidity meter, producing a seconds value of 60 at the end of a minute (e.g., 0x1E). Date deserialization already properly handles this with a fallback date of 1980-01-01; similarly fall back to 00:00:00 in case of invalid timestamps.
Thank you for the heads-up! I've updated you pull request and added additional information to the commit message. |
I'm finding at the top of every minute, it is possible to get the value error in the deserialize_time function.
You can produce the error with:
The text was updated successfully, but these errors were encountered: