You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
parse('') raises ValueError although parse() documents it never raises #153
parse() documents that it never raises ValueError and always returns errors in the tuple, but the empty-string path raises instead:
Docstring (current main):
Note that this does not raise a ValueError; instead any error is returned as the second value in the tuple.
Repro:
importjson5json5.loads('') # ValueError — documented and finejson5.parse('') # ValueError: Empty strings are not legal JSON5json5.parse(' ', consume_trailing=False) # returns (None, '<string>:1 ...', 3) as documented
So callers that follow the docstring and use the tuple result get an exception for one specific input, while every other malformed input ('x', '{', '}', whitespace-only, …) comes back as (None, err, pos) as promised.
Fix would be one line in parse():
ifnots:
returnNone, 'Empty strings are not legal JSON5', 0
(or keep the raise and adjust the docstring). The behavior snuck past the docstring's "Raises:" section too, which only lists UnicodeDecodeError.
Activity