Fix #98 - Parse empty inline tables
This commit is contained in:
parent
3521cccf3f
commit
1921458b46
5
toml.py
5
toml.py
|
@ -335,9 +335,14 @@ def loads(s, _dict=dict):
|
||||||
def _load_inline_object(line, currentlevel, _dict, multikey=False, multibackslash=False):
|
def _load_inline_object(line, currentlevel, _dict, multikey=False, multibackslash=False):
|
||||||
candidate_groups = line[1:-1].split(",")
|
candidate_groups = line[1:-1].split(",")
|
||||||
groups = []
|
groups = []
|
||||||
|
if len(candidate_groups) == 1 and not candidate_groups[0].strip():
|
||||||
|
candidate_groups.pop()
|
||||||
while len(candidate_groups) > 0:
|
while len(candidate_groups) > 0:
|
||||||
candidate_group = candidate_groups.pop(0)
|
candidate_group = candidate_groups.pop(0)
|
||||||
|
try:
|
||||||
_, value = candidate_group.split('=', 1)
|
_, value = candidate_group.split('=', 1)
|
||||||
|
except ValueError:
|
||||||
|
raise TomlDecodeError("Invalid inline table encountered")
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
if (value[0] == value[-1] and value[0] in ('"', "'")) or \
|
if (value[0] == value[-1] and value[0] in ('"', "'")) or \
|
||||||
value[0] in '-0123456789' or \
|
value[0] in '-0123456789' or \
|
||||||
|
|
Loading…
Reference in New Issue