Opened 15 years ago
Closed 13 years ago
#11970 closed Bug (fixed)
JSON Deserialiser throws ValueError on malformed input
Reported by: | Malcolm Box | Owned by: | nobody |
---|---|---|---|
Component: | Core (Serialization) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Malcolm Box | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
/core/serializers/json.py Deserializer uses simplejson to parse the input string. If this input is malformed, then simplejson throws a ValueError exception.
However, the serializer interface appears (see XML & base.py) that it should raise a base.DeserializationError when deserialization fails, not a ValueError. Users of the deserializer (e.g. django-restapi) then fail to handle the ValueError, resulting in Internal Server (500) errors.
The fix is to catch ValueError in json.py (around line 40) and re-raise as a DeserializationError.
Simple patch attached.
Attachments (4)
Change History (13)
by , 15 years ago
Attachment: | patch.diff added |
---|
comment:1 by , 15 years ago
Has patch: | set |
---|
comment:2 by , 15 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 14 years ago
Cc: | added |
---|
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:5 by , 14 years ago
Easy pickings: | unset |
---|---|
Needs tests: | unset |
Version: | 1.1 → SVN |
comment:6 by , 13 years ago
Patch needs improvement: | set |
---|---|
UI/UX: | unset |
This is causing a test to fail related to fixtures:
FAIL: test_fixture_loading (regressiontests.multiple_database.tests.FixtureTestCase) Multi-db fixtures are loaded correctly ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/admin/Projects/django/django-git/tests/regressiontests/multiple_database/tests.py", line 1639, in test_fixture_loading self.fail('"Dive into Python" should exist on other database') AssertionError: "Dive into Python" should exist on other database ----------------------------------------------------------------------
comment:7 by , 13 years ago
Patch needs improvement: | unset |
---|
Sorry, there was an error in the previous patch (missing **options
). Fixed.
comment:8 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Fix for problem