Index: Lib/json/tests/test_indent.py =================================================================== --- Lib/json/tests/test_indent.py (revision 84213) +++ Lib/json/tests/test_indent.py (working copy) @@ -2,6 +2,7 @@ import json import textwrap +from StringIO import StringIO class TestIndent(TestCase): def test_indent(self): @@ -39,3 +40,19 @@ self.assertEquals(h1, h) self.assertEquals(h2, h) self.assertEquals(d2, expect) + + def test_indent0(self): + h = {3: 1, 4: 2} + + def check(indent, expected): + d1 = json.dumps(h, indent=indent) + self.assertEquals(d1, expected) + + sio = StringIO() + json.dump({3: 1, 4: 2}, sio, indent=indent) + self.assertEquals(sio.getvalue(), expected) + + # indent=0 should emit newlines + check(0, '{\n"3": 1, \n"4": 2\n}') + # indent=None is more compact + check(None, '{"3": 1, "4": 2}') Index: Lib/json/encoder.py =================================================================== --- Lib/json/encoder.py (revision 84213) +++ Lib/json/encoder.py (working copy) @@ -251,7 +251,7 @@ if (_one_shot and c_make_encoder is not None - and not self.indent and not self.sort_keys): + and self.indent is None and not self.sort_keys): _iterencode = c_make_encoder( markers, self.default, _encoder, self.indent, self.key_separator, self.item_separator, self.sort_keys,