[New-bugs-announce] [issue9233] json.load failure when C optimizations aren't built
Fred L. Drake, Jr.
report at bugs.python.org
Mon Jul 12 17:47:45 CEST 2010
New submission from Fred L. Drake, Jr. <fdrake at acm.org>:
The json decoder doesn't pass tests when the C optimizations in the _json module aren't available. The actual test failures appear fairly superficial, but aren't the limit of the problems.
Empty objects are converted to empty lists instead of empty dictionaries when _json isn't available; test attached.
Issue 5723 notes that the pure-Python implementation isn't tested; fixing that might have avoided these problems.
Test failures from Python 2.6.5:
======================================================================
ERROR: test_c_encode_basestring_ascii (json.tests.test_encode_basestring_ascii.TestEncodeBaseStringAscii)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fdrake/src/Python-2.6.5/Lib/json/tests/test_encode_basestring_ascii.py", line 29, in test_c_encode_basestring_ascii
self._test_encode_basestring_ascii(json.encoder.c_encode_basestring_ascii)
File "/home/fdrake/src/Python-2.6.5/Lib/json/tests/test_encode_basestring_ascii.py", line 32, in _test_encode_basestring_ascii
fname = encode_basestring_ascii.__name__
AttributeError: 'NoneType' object has no attribute '__name__'
======================================================================
ERROR: test_c_scanstring (json.tests.test_scanstring.TestScanString)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fdrake/src/Python-2.6.5/Lib/json/tests/test_scanstring.py", line 13, in test_c_scanstring
self._test_scanstring(json.decoder.c_scanstring)
File "/home/fdrake/src/Python-2.6.5/Lib/json/tests/test_scanstring.py", line 17, in _test_scanstring
scanstring('"z\\ud834\\udd20x"', 1, None, True),
TypeError: 'NoneType' object is not callable
======================================================================
FAIL: test_encode_basestring_ascii (json.tests.test_speedups.TestSpeedups)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fdrake/src/Python-2.6.5/Lib/json/tests/test_speedups.py", line 13, in test_encode_basestring_ascii
self.assertEquals(encoder.encode_basestring_ascii.__module__, "_json")
AssertionError: 'json.encoder' != '_json'
======================================================================
FAIL: test_scanstring (json.tests.test_speedups.TestSpeedups)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fdrake/src/Python-2.6.5/Lib/json/tests/test_speedups.py", line 9, in test_scanstring
self.assertEquals(decoder.scanstring.__module__, "_json")
AssertionError: 'json.decoder' != '_json'
Test failures from 2.7:
======================================================================
ERROR: test_c_scanstring (json.tests.test_scanstring.TestScanString)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fdrake/src/Python-2.7/Lib/json/tests/test_scanstring.py", line 13, in test_c_scanstring
self._test_scanstring(json.decoder.c_scanstring)
File "/home/fdrake/src/Python-2.7/Lib/json/tests/test_scanstring.py", line 17, in _test_scanstring
scanstring('"z\\ud834\\udd20x"', 1, None, True),
TypeError: 'NoneType' object is not callable
======================================================================
FAIL: test_encode_basestring_ascii (json.tests.test_speedups.TestSpeedups)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fdrake/src/Python-2.7/Lib/json/tests/test_speedups.py", line 12, in test_encode_basestring_ascii
self.assertEquals(encoder.encode_basestring_ascii.__module__, "_json")
AssertionError: 'json.encoder' != '_json'
======================================================================
FAIL: test_scanstring (json.tests.test_speedups.TestSpeedups)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fdrake/src/Python-2.7/Lib/json/tests/test_speedups.py", line 8, in test_scanstring
self.assertEquals(decoder.scanstring.__module__, "_json")
AssertionError: 'json.decoder' != '_json'
----------
components: Library (Lib)
files: test-empty-json-object.diff
keywords: patch
messages: 110099
nosy: fdrake
priority: normal
severity: normal
status: open
title: json.load failure when C optimizations aren't built
type: behavior
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file17966/test-empty-json-object.diff
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9233>
_______________________________________
More information about the New-bugs-announce
mailing list