From aa2fabb43ab78ffb55b3f7d94b1a454ba51ed162 Mon Sep 17 00:00:00 2001 From: Uiri Date: Mon, 4 Mar 2013 16:37:35 -0500 Subject: [PATCH] Fix issue with overwriting duplicate keys. --- toml.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/toml.py b/toml.py index 0e4c9ce..037c64c 100644 --- a/toml.py +++ b/toml.py @@ -74,7 +74,11 @@ def loads(s): pair[0] = pair[0].strip() pair[1] = pair[1].strip() value = load_value(pair[1]) - currentlevel[pair[0]] = value + try: + currentlevel[pair[0]] + raise Exception("Duplicate keys!") + except KeyError: + currentlevel[pair[0]] = value return retval def load_value(v):