From b4fe7d00e03ea4f8ea596e1326df905542457444 Mon Sep 17 00:00:00 2001 From: Josh Austin Date: Mon, 5 Oct 2015 12:42:32 -0400 Subject: [PATCH] comment out values of None without crashing, https://github.com/toml-lang/toml/issues/30 --- pytoml/writer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pytoml/writer.py b/pytoml/writer.py index a43f6ad..e8d054a 100644 --- a/pytoml/writer.py +++ b/pytoml/writer.py @@ -100,6 +100,9 @@ def dump(fout, obj): tables.append((name + (k,), v, False)) elif isinstance(v, list) and v and all(isinstance(o, dict) for o in v): tables.extend((name + (k,), d, True) for d in reversed(v)) + elif v is None: + fout.write( + '#{} = VALUE # To use: uncomment and replace VALUE with your own value.\n'.format(_escape_id(k))) else: fout.write('{} = {}\n'.format(_escape_id(k), _format_value(v)))