ids were based on the string, rather than the actual object which causes incorrect detection of circular references (#303)
Fix #295
Co-authored-by: Dirk-Philip van Herwaarden <dirkphilip@dirkphilipsmbp.home>
diff --git a/toml/encoder.py b/toml/encoder.py
index d9e557e..bf17a72 100644
--- a/toml/encoder.py
+++ b/toml/encoder.py
@@ -61,7 +61,7 @@
retval += addtoretval
outer_objs = [id(o)]
while sections:
- section_ids = [id(section) for section in sections]
+ section_ids = [id(section) for section in sections.values()]
for outer_obj in outer_objs:
if outer_obj in section_ids:
raise ValueError("Circular reference detected")