summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/forms
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-06-20 15:16:37 -0400
committerTim Graham <timograham@gmail.com>2017-09-25 17:11:06 -0400
commit98706bb35e7de0e445cc336f669919047bf46b75 (patch)
tree976c38c9985dbd9d01c8a65244cde122e5ee0409 /django/contrib/postgres/forms
parentcfff2af02be40106d4759cc6f8bfa476ce82421c (diff)
Refs #27857 -- Replaced json.loads() ValueError exception catching with JSONDecodeError.
Diffstat (limited to 'django/contrib/postgres/forms')
-rw-r--r--django/contrib/postgres/forms/hstore.py2
-rw-r--r--django/contrib/postgres/forms/jsonb.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/django/contrib/postgres/forms/hstore.py b/django/contrib/postgres/forms/hstore.py
index 984227ff71..f5af8f10e3 100644
--- a/django/contrib/postgres/forms/hstore.py
+++ b/django/contrib/postgres/forms/hstore.py
@@ -28,7 +28,7 @@ class HStoreField(forms.CharField):
if not isinstance(value, dict):
try:
value = json.loads(value)
- except ValueError:
+ except json.JSONDecodeError:
raise ValidationError(
self.error_messages['invalid_json'],
code='invalid_json',
diff --git a/django/contrib/postgres/forms/jsonb.py b/django/contrib/postgres/forms/jsonb.py
index 2cb6092cb7..158ab8fdb9 100644
--- a/django/contrib/postgres/forms/jsonb.py
+++ b/django/contrib/postgres/forms/jsonb.py
@@ -29,7 +29,7 @@ class JSONField(forms.CharField):
return value
try:
converted = json.loads(value)
- except ValueError:
+ except json.JSONDecodeError:
raise forms.ValidationError(
self.error_messages['invalid'],
code='invalid',
@@ -45,7 +45,7 @@ class JSONField(forms.CharField):
return initial
try:
return json.loads(data)
- except ValueError:
+ except json.JSONDecodeError:
return InvalidJSONInput(data)
def prepare_value(self, value):