Просмотр исходного кода

chore(json): Always use sentry.utils.json (#20090)

Evan Purkhiser 4 лет назад
Родитель
Сommit
fda7167f29

+ 1 - 2
src/sentry/api/base.py

@@ -17,7 +17,6 @@ from rest_framework.authentication import SessionAuthentication
 from rest_framework.exceptions import ParseError
 from rest_framework.exceptions import ParseError
 from rest_framework.response import Response
 from rest_framework.response import Response
 from rest_framework.views import APIView
 from rest_framework.views import APIView
-from simplejson import JSONDecodeError
 
 
 from sentry import tsdb
 from sentry import tsdb
 from sentry.auth import access
 from sentry.auth import access
@@ -167,7 +166,7 @@ class Endpoint(APIView):
 
 
         try:
         try:
             request.json_body = json.loads(request.body)
             request.json_body = json.loads(request.body)
-        except JSONDecodeError:
+        except json.JSONDecodeError:
             return
             return
 
 
     def initialize_request(self, request, *args, **kwargs):
     def initialize_request(self, request, *args, **kwargs):

+ 2 - 1
src/sentry/api/validators/sentry_apps/schema.py

@@ -1,12 +1,13 @@
 from __future__ import absolute_import
 from __future__ import absolute_import
 
 
 import logging
 import logging
-import json
 
 
 from jsonschema import Draft7Validator
 from jsonschema import Draft7Validator
 from jsonschema.exceptions import best_match
 from jsonschema.exceptions import best_match
 from jsonschema.exceptions import ValidationError as SchemaValidationError
 from jsonschema.exceptions import ValidationError as SchemaValidationError
 
 
+from sentry.utils import json
+
 
 
 logger = logging.getLogger(__name__)
 logger = logging.getLogger(__name__)
 
 

+ 2 - 1
src/sentry/conf/locale.py

@@ -1,9 +1,10 @@
 from __future__ import absolute_import
 from __future__ import absolute_import
 
 
 import os
 import os
-import json
 import sentry
 import sentry
 
 
+from sentry.utils import json
+
 
 
 # change locale file dir name to locale code
 # change locale file dir name to locale code
 def dirname_to_local(dir_name):
 def dirname_to_local(dir_name):

+ 1 - 1
src/sentry/data_export/models.py

@@ -1,6 +1,5 @@
 from __future__ import absolute_import
 from __future__ import absolute_import
 
 
-import json
 import logging
 import logging
 from django.conf import settings
 from django.conf import settings
 from django.core.urlresolvers import reverse
 from django.core.urlresolvers import reverse
@@ -15,6 +14,7 @@ from sentry.db.models import (
     Model,
     Model,
     sane_repr,
     sane_repr,
 )
 )
+from sentry.utils import json
 from sentry.utils.http import absolute_uri
 from sentry.utils.http import absolute_uri
 
 
 from .base import ExportQueryType, ExportStatus, DEFAULT_EXPIRATION
 from .base import ExportQueryType, ExportStatus, DEFAULT_EXPIRATION

+ 2 - 1
src/sentry/db/models/fields/jsonfield.py

@@ -1,5 +1,5 @@
 from __future__ import absolute_import, unicode_literals
 from __future__ import absolute_import, unicode_literals
-import json
+
 import datetime
 import datetime
 import six
 import six
 
 
@@ -11,6 +11,7 @@ from django.db import models
 from django.db.models.lookups import Exact, IExact, In, Contains, IContains
 from django.db.models.lookups import Exact, IExact, In, Contains, IContains
 from django.utils.translation import ugettext_lazy as _
 from django.utils.translation import ugettext_lazy as _
 
 
+from sentry.utils import json
 from sentry.db.models.utils import Creator
 from sentry.db.models.utils import Creator
 
 
 
 

+ 1 - 2
src/sentry/identity/oauth2.py

@@ -7,7 +7,6 @@ from six.moves.urllib.parse import parse_qsl, urlencode
 from uuid import uuid4
 from uuid import uuid4
 from time import time
 from time import time
 from requests.exceptions import SSLError
 from requests.exceptions import SSLError
-from simplejson import JSONDecodeError
 from django.views.decorators.csrf import csrf_exempt
 from django.views.decorators.csrf import csrf_exempt
 
 
 from sentry.auth.exceptions import IdentityNotValid
 from sentry.auth.exceptions import IdentityNotValid
@@ -292,7 +291,7 @@ class OAuth2CallbackView(PipelineView):
                 "error": "Could not verify SSL certificate",
                 "error": "Could not verify SSL certificate",
                 "error_description": u"Ensure that {} has a valid SSL certificate".format(url),
                 "error_description": u"Ensure that {} has a valid SSL certificate".format(url),
             }
             }
-        except JSONDecodeError:
+        except json.JSONDecodeError:
             logger.info("identity.oauth2.json-error", extra={"url": self.access_token_url})
             logger.info("identity.oauth2.json-error", extra={"url": self.access_token_url})
             return {
             return {
                 "error": "Could not decode a JSON Response",
                 "error": "Could not decode a JSON Response",

+ 1 - 2
src/sentry/integrations/bitbucket/webhook.py

@@ -13,7 +13,6 @@ from django.utils.decorators import method_decorator
 from django.views.decorators.csrf import csrf_exempt
 from django.views.decorators.csrf import csrf_exempt
 from django.views.generic import View
 from django.views.generic import View
 from django.utils import timezone
 from django.utils import timezone
-from simplejson import JSONDecodeError
 from sentry.models import Commit, CommitAuthor, Organization, Repository
 from sentry.models import Commit, CommitAuthor, Organization, Repository
 from sentry.plugins.providers import IntegrationRepositoryProvider
 from sentry.plugins.providers import IntegrationRepositoryProvider
 from sentry.utils import json
 from sentry.utils import json
@@ -191,7 +190,7 @@ class BitbucketWebhookEndpoint(View):
 
 
         try:
         try:
             event = json.loads(body.decode("utf-8"))
             event = json.loads(body.decode("utf-8"))
-        except JSONDecodeError:
+        except json.JSONDecodeError:
             logger.error(
             logger.error(
                 PROVIDER_NAME + ".webhook.invalid-json",
                 PROVIDER_NAME + ".webhook.invalid-json",
                 extra={"organization_id": organization.id},
                 extra={"organization_id": organization.id},

+ 1 - 2
src/sentry/integrations/bitbucket_server/webhook.py

@@ -11,7 +11,6 @@ from django.utils import timezone
 from django.utils.decorators import method_decorator
 from django.utils.decorators import method_decorator
 from django.views.decorators.csrf import csrf_exempt
 from django.views.decorators.csrf import csrf_exempt
 from django.views.generic.base import View
 from django.views.generic.base import View
-from simplejson import JSONDecodeError
 from sentry.models import Commit, CommitAuthor, Organization, Repository
 from sentry.models import Commit, CommitAuthor, Organization, Repository
 from sentry.plugins.providers import IntegrationRepositoryProvider
 from sentry.plugins.providers import IntegrationRepositoryProvider
 from sentry.utils import json
 from sentry.utils import json
@@ -139,7 +138,7 @@ class BitbucketServerWebhookEndpoint(View):
 
 
         try:
         try:
             event = json.loads(body.decode("utf-8"))
             event = json.loads(body.decode("utf-8"))
-        except JSONDecodeError:
+        except json.JSONDecodeError:
             logger.error(
             logger.error(
                 PROVIDER_NAME + ".webhook.invalid-json",
                 PROVIDER_NAME + ".webhook.invalid-json",
                 extra={"organization_id": organization.id, "integration_id": integration_id},
                 extra={"organization_id": organization.id, "integration_id": integration_id},

+ 1 - 2
src/sentry/integrations/github/webhook.py

@@ -14,7 +14,6 @@ from django.utils.decorators import method_decorator
 from django.views.decorators.csrf import csrf_exempt
 from django.views.decorators.csrf import csrf_exempt
 from django.views.generic import View
 from django.views.generic import View
 from django.utils import timezone
 from django.utils import timezone
-from simplejson import JSONDecodeError
 from sentry import options
 from sentry import options
 from sentry.constants import ObjectStatus
 from sentry.constants import ObjectStatus
 from sentry.models import (
 from sentry.models import (
@@ -440,7 +439,7 @@ class GitHubWebhookBase(View):
 
 
         try:
         try:
             event = json.loads(body.decode("utf-8"))
             event = json.loads(body.decode("utf-8"))
-        except JSONDecodeError:
+        except json.JSONDecodeError:
             logger.error(
             logger.error(
                 "github.webhook.invalid-json", extra=self.get_logging_data(), exc_info=True
                 "github.webhook.invalid-json", extra=self.get_logging_data(), exc_info=True
             )
             )

+ 1 - 2
src/sentry/integrations/github_enterprise/webhook.py

@@ -11,7 +11,6 @@ from django.utils.crypto import constant_time_compare
 from django.utils.decorators import method_decorator
 from django.utils.decorators import method_decorator
 from django.views.decorators.csrf import csrf_exempt
 from django.views.decorators.csrf import csrf_exempt
 from django.views.generic import View
 from django.views.generic import View
-from simplejson import JSONDecodeError
 from sentry.models import Integration
 from sentry.models import Integration
 from sentry.utils import json
 from sentry.utils import json
 from sentry.integrations.github.webhook import (
 from sentry.integrations.github.webhook import (
@@ -128,7 +127,7 @@ class GitHubEnterpriseWebhookBase(View):
 
 
         try:
         try:
             event = json.loads(body.decode("utf-8"))
             event = json.loads(body.decode("utf-8"))
-        except JSONDecodeError:
+        except json.JSONDecodeError:
             logger.warning(
             logger.warning(
                 "github_enterprise.webhook.invalid-json",
                 "github_enterprise.webhook.invalid-json",
                 extra=self.get_logging_data(),
                 extra=self.get_logging_data(),

Некоторые файлы не были показаны из-за большого количества измененных файлов