Closed
Description
Feature or enhancement
Proposal:
tomllib.loads
only accepts str as input. Given bytes, it throws
TypeError: a bytes-like object is required, not 'str'
This is a bubbled up exception from the replace
method on line
cpython/Lib/tomllib/_parser.py
Line 74 in 4129a74
While at it, I also propose catching any AttributeErrors from this line of code and raising the same new TypeError instead. As a result, a sensible TypeError is raised in nearly all cases where incorrect type is passed in.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
Original issue report by @mechsin on Tomli's issue tracker: hukkin/tomli#223
PR: #124587