From 0288e8fe4e81fbc1158a5d15294cff0db487e020 Mon Sep 17 00:00:00 2001 From: eliwaksbaum <62363023+eliwaksbaum@users.noreply.github.com> Date: Mon, 25 Oct 2021 13:50:44 -0400 Subject: [PATCH] saumelcolvin's multiline string fix uiri#265 --- toml/decoder.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/toml/decoder.py b/toml/decoder.py index bf400e9..4ec5b1d 100644 --- a/toml/decoder.py +++ b/toml/decoder.py @@ -363,6 +363,7 @@ def loads(s, _dict=dict, decoder=None): " Reached end of file.", original, len(s)) s = ''.join(sl) s = s.split('\n') + multilevel = None multikey = None multilinestr = "" multibackslash = False @@ -395,7 +396,8 @@ def loads(s, _dict=dict, decoder=None): value, vtype = decoder.load_value(multilinestr) except ValueError as err: raise TomlDecodeError(str(err), original, pos) - currentlevel[multikey] = value + multilevel[multikey] = value + multilevel = None multikey = None multilinestr = "" else: @@ -513,7 +515,7 @@ def loads(s, _dict=dict, decoder=None): except ValueError as err: raise TomlDecodeError(str(err), original, pos) if ret is not None: - multikey, multilinestr, multibackslash = ret + multilevel, multikey, multilinestr, multibackslash = ret return retval @@ -783,7 +785,7 @@ def load_line(self, line, currentlevel, multikey, multibackslash): raise ValueError("Duplicate keys!") except KeyError: if multikey: - return multikey, multilinestr, multibackslash + return currentlevel, multikey, multilinestr, multibackslash else: currentlevel[pair[0]] = value