summaryrefslogtreecommitdiffstats
path: root/Lib/tomllib/_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/tomllib/_parser.py')
-rw-r--r--Lib/tomllib/_parser.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/tomllib/_parser.py b/Lib/tomllib/_parser.py
index 45ca7a8..5671326 100644
--- a/Lib/tomllib/_parser.py
+++ b/Lib/tomllib/_parser.py
@@ -71,7 +71,12 @@ def loads(s: str, /, *, parse_float: ParseFloat = float) -> dict[str, Any]: # n
# The spec allows converting "\r\n" to "\n", even in string
# literals. Let's do so to simplify parsing.
- src = s.replace("\r\n", "\n")
+ try:
+ src = s.replace("\r\n", "\n")
+ except (AttributeError, TypeError):
+ raise TypeError(
+ f"Expected str object, not '{type(s).__qualname__}'"
+ ) from None
pos = 0
out = Output(NestedDict(), Flags())
header: Key = ()