-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Forthcoming changes in TOML v1.1.0 will cause TOMLDecodeError. tomllib.loads doesn't support optional seconds in times. #103992
Comments
Cc. @hauntsaninja / @hukkin for tomllib |
It's mentioned on the TOML github: https://github.com/toml-lang/toml/blob/main/toml.md#user-content-local-time It looks to me like the decision to allow optional seconds was taken, but could have been better communicated. |
Thanks for bringing this up! hukkin has done an excellent job staying on top of changes and has a PR for this specific change ready to go: https://github.com/hukkin/tomli/pull/203/files PEP 680 specifies we can treat minor revisions to TOML as bug fixes, so when v1.1 is released we should have the option to backport it if we think that's wise: https://peps.python.org/pep-0680/#stability-of-toml Currently defaulting to avoid shipping changes until v1.1 is released: toml-lang/toml#928 cc @pradyunsg in case you have opinions for how the release cycle of TOML and CPython should intersect :-) |
You're welcome. Great job hukkin! I was just very surprised earlier today to see a Python core library 'fail' a toml-test. But I'd got my wires crossed, and didn't realise I was using cutting edge tests, for features ahead of Toml 1.0.0 |
We should be able to pull it in the next minor version of Python, once "upstream" (AKA me) cuts TOML v1.1.0. I don't think we should try backporting to an older minor version in a patch release, but anything stated in the PEP takes precedence over my opinions. :) |
[Edit] I erroneously assumed the "minimal configuration file format", that I personally find to be a pleasant alternative to JSON, was done and dusted. But TOML is still very much under active development. On its main branch.
Python 3.12 is compliant with TOML v1.0.0 as far as I'm aware. But optional seconds, and other issues will arise if TOML v1.1.0 files are attempted to be loaded with tomllib. This is absolutely not a request to support TOML v1.1.0.
This issue is an informational advanced warning only, of changes coming down the line. Feel free to decide not to support them all (TOML v1.1 is completely unnecessary for my projects, and I won't be supporting it). But if so, it's still good to make a decision, and record that somewhere. If nothing else so it is clear what should be included in test data.
Background: In summer last year (2022) the TOML language's latest version relaxed the requirement for seconds to be specified in a time: toml-lang/toml@7e8a748
A test for optional seconds was also added to toml-test's development version: https://github.com/BurntSushi/toml-test/blob/master/tests/valid/datetime/no-seconds.toml
Implications: In Python 3.12, tomllib requires seconds to be present. Currently in the absence of seconds, the regex _TIME_RE_STR does not match. Otherwise both local variables called sec_str could not be defined. So if others decide to support TOML v1.1, this will affects all platforms.
Regex:
cpython/Lib/tomllib/_re.py
Line 17 in fbf3596
sec_str:
cpython/Lib/tomllib/_re.py
Line 74 in fbf3596
sec_str:
cpython/Lib/tomllib/_re.py
Line 101 in fbf3596
Bug report
The text was updated successfully, but these errors were encountered: