[New-bugs-announce] [issue22297] json encoding broken for

Edward O report at bugs.python.org
Fri Aug 29 13:00:34 CEST 2014


New submission from Edward O:

_make_iterencode in python2.7/json/encoder.py encodes custom enum types incorrectly (the label will be printed without '"') because of these lines (line 320 in 2.7.6):
    elif isinstance(value, (int, long)):
        yield buf + str(value)

in constract, _make_iterencode in python 3 explicitly supports the enum types:

    elif isinstance(value, int):
        # Subclasses of int/float may override __str__, but we still
        # want to encode them as integers/floats in JSON. One example
        # within the standard library is IntEnum.
        yield buf + str(int(value))

----------
components: Library (Lib)
messages: 226057
nosy: eddygeek
priority: normal
severity: normal
status: open
title: json encoding broken for
type: behavior
versions: Python 2.7

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


More information about the New-bugs-announce mailing list