[New-bugs-announce] [issue24540] Documentation about skipkeys parameter for json.dumps is incorrect

Matthew Havard report at bugs.python.org
Tue Jun 30 22:16:22 CEST 2015


New submission from Matthew Havard:

The documentation from json.dumps says this about skipkeys:

    If ``skipkeys`` is false then ``dict`` keys that are not basic types
    (``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped
    instead of raising a ``TypeError``.

However, that contradicts the docstrings for JSONEncoder in the encoder.py file, and json.dump in the same file, __init__.py:

json.dump:
    If ``skipkeys`` is true then ``dict`` keys that are not basic types
    (``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped
    instead of raising a ``TypeError``.

JSONEncoder:
        If skipkeys is false, then it is a TypeError to attempt
        encoding of keys that are not str, int, long, float or None.  If
        skipkeys is True, such items are simply skipped.

So the fix is just that the word "false" to "true".

----------
messages: 245997
nosy: Matthew Havard
priority: normal
severity: normal
status: open
title: Documentation about skipkeys parameter for json.dumps is incorrect
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24540>
_______________________________________


More information about the New-bugs-announce mailing list