This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients docs@python, terry.reedy
Date 2010-09-03.21:32:50
SpamBayes Score 4.2682093e-09
Marked as misclassified No
Message-id <1283549572.36.0.344374385965.issue9767@psf.upfronthosting.co.za>
In-reply-to
Content
I ran doctest on LibRef 17.2 json saved as .txt. There are 4 failures: 2 are clearly doc issues, the other 2 I do not know. I hope someone reads this who is already familiar

DOC PATCHES
    dumps(2 + 1j, cls=ComplexEncoder)
should be
    json.dumps(2 + 1j, cls=ComplexEncoder)
and
    JSONEncoder().encode({"foo": ["bar", "baz"]})
should be
    json.JSONEncoder().encode({"foo": ["bar", "baz"]})

Needing similar additions in example code (not caught by doctest) are
           return JSONEncoder.default(self, o)
        for chunk in JSONEncoder().iterencode(bigobject):

Those fixes leave 2 failures I an unclear about and hope a json expert will comment on.

1.'''
Failed example:
    print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4))
Expected:
    {
        "4": 5,
        "6": 7
    }
Got:
    {
        "4": 5, 
        "6": 7
    }
'''
The difference is that json puts a trailing space after '5,'. Should it? or should one be added to the doc?

2. '''
Failed example:
    list(ComplexEncoder().iterencode(2 + 1j))
Expected:
    ['[', '2.0', ', ', '1.0', ']']
Got:
    ['[2.0', ', 1.0', ']']
'''
Without knowing how the default iterencode interacts with the overwridden .default() method, I have no idea.
History
Date User Action Args
2010-09-03 21:32:52terry.reedysetrecipients: + terry.reedy, docs@python
2010-09-03 21:32:52terry.reedysetmessageid: <1283549572.36.0.344374385965.issue9767@psf.upfronthosting.co.za>
2010-09-03 21:32:51terry.reedylinkissue9767 messages
2010-09-03 21:32:50terry.reedycreate