Repository navigation
Document errors that come from implementation limits - #310
faresrafat3 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #310 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 535 535
Branches 100 100
=========================================
Hits 535 535 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hi @hukkin — checking in on this PR. It documents the implementation-limit errors that tomli can raise. CI is green and all tests pass. Let me know if there's anything you'd like me to adjust. |
|
Thanks for the review @hukkin! I've updated the PR to document the implementation-limit errors that tomli can raise. CI is green and all tests pass. Let me know if there's anything else you'd like me to adjust. |
|
I think it would be enough to say something like “Note that Tomli may raise a different exception if an implementation-defined limit is exceeded, such as |
|
Done — replaced the expanded explanation with exactly that wording. The worked examples and the |
|
Hi @encukou — the PR now carries exactly the wording you suggested, replacing the expanded explanation:
The worked examples and the Ready for review whenever you get to it — happy to adjust further if it still needs trimming. |
45cc176 to
e83796a
Compare
TOMLDecodeError is raised only for invalid TOML. Errors that come from Tomli's own implementation limits propagate unchanged, because the document may be valid TOML that this implementation cannot represent: - ValueError for a decimal integer longer than Python's integer string conversion limit (4300 digits by default) - RecursionError for a deeply nested inline table or inline array Fixes hukkin#309.
e83796a to
47968f4
Compare
|
Rebased this onto current The wording is the one @encukou suggested, with one adjustment: it says "deeply nested The commit is now signed with my verified GitHub address, so it is attributed to my The verification section in the description lists the actual output on |
Fixes #309.
This is the documentation update that #309 ends up calling for. The maintainer of Tomli
agreed in that issue that invalid TOML should stay distinguishable from an error caused
by an implementation limit, and that the
RecursionErrorcase needed documenting too:@encukou suggested the wording, and this implements it:
The note is added to the "Handle invalid TOML" section of the README, right after the
example:
TOMLDecodeErrorcovers invalid TOML only, while errors caused by Tomli's ownimplementation limits propagate unchanged, because the document may be valid TOML that
this implementation cannot represent.
One wording adjustment against the suggestion above: the note says "deeply nested inline
tables or arrays" rather than "deeply nested tables". The maintainer's comment above
spoke of a "deeply nested inline table or array", so the note names both.
Verification
Checked against
master(2.5.0) by running the library from this branch underCPython 3.12:
The two errors named in the note are distinct: an oversized integer raises a plain
ValueError, and deep nesting raisesRecursionError. Both are limits of theimplementation rather than of TOML, which is why the note calls them
"implementation-defined".
mdformat --check README.mdpasses locally with the versions pinned in.pre-commit-config.yaml, and the full CI matrix is green.