On this page
tomllib.TOMLDecodeError
Prev: tomllib.loads | Up: tomllib
Rel: tomllib.load, tomllib.loads
Ref: docs.python.org โ tomllib.TOMLDecodeError
Tags: #public #python3 #stdlib #tomllib
Import
import tomllib
from tomllib import TOMLDecodeError
Signature & Overview
tomllib.TOMLDecodeError(msg: 'str' = <class 'tomllib._parser.DEPRECATED_DEFAULT'>, doc: 'str' = <class 'tomllib._parser.DEPRECATED_DEFAULT'>, pos: 'Pos' = <class 'tomllib._parser.DEPRECATED_DEFAULT'>, *args: 'Any')
An error raised if a document is not valid TOML.
Methods & Attributes
TOMLDecodeError.add_note(self, note, /)โ Add a note to the exceptionTOMLDecodeError.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import tomllib
try:
tomllib.loads("invalid = [1, 2")
except tomllib.TOMLDecodeError as exc:
assert isinstance(exc, ValueError)
Gotchas
- Subclass of
ValueError(Python 3.11+): Raised on malformed TOML syntax, duplicate keys, or invalid dates.
REPL Inspect
from tomllib import TOMLDecodeError
help(TOMLDecodeError)
Linked from
Related notes
- tuts/python3/stdlib_module/tomllib/load Linked here; links to this page; shared tags: #stdlib, #tomllib
- tuts/python3/stdlib_module/tomllib/loads Linked here; links to this page; shared tags: #stdlib, #tomllib
- tuts/python3/stdlib_module/tomllib Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib