From e879373d2e86a02c1d9b13438e6dadfdad935577 Mon Sep 17 00:00:00 2001 From: Aplet123 Date: Wed, 23 Jun 2021 07:36:54 -0400 Subject: [PATCH] fix issue #364 and add a test for it --- tests/test_api.py | 4 ++++ toml/encoder.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 1acc26f..ff2e6cb 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -43,6 +43,10 @@ def test_bug_196(): assert round_trip_bug_dict == bug_dict assert round_trip_bug_dict['x'] == bug_dict['x'] +def test_bug_364(): + bug_dict = {"foo": [{"bar": {}, "moot": {"a": 1}}]} + round_trip_bug_dict = toml.loads(toml.dumps(bug_dict)) + assert bug_dict == round_trip_bug_dict def test_valid_tests(): valid_dir = "toml-test/tests/valid/" diff --git a/toml/encoder.py b/toml/encoder.py index bf17a72..88ef077 100644 --- a/toml/encoder.py +++ b/toml/encoder.py @@ -212,9 +212,9 @@ def dump_sections(self, o, sup): s1, d1 = self.dump_sections(d[dsec], sup + qsection + "." + dsec) + arraytabstr += ("[" + sup + qsection + + "." + dsec + "]\n") if s1: - arraytabstr += ("[" + sup + qsection + - "." + dsec + "]\n") arraytabstr += s1 for s1 in d1: newd[dsec + "." + s1] = d1[s1]