Refs #23919 -- Replaced six.reraise by raise
This commit is contained in:
parent
d170c63351
commit
6e55e1d88a
|
@ -1,4 +1,3 @@
|
||||||
import sys
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from django.contrib.admin import FieldListFilter
|
from django.contrib.admin import FieldListFilter
|
||||||
|
@ -17,7 +16,6 @@ from django.core.exceptions import (
|
||||||
from django.core.paginator import InvalidPage
|
from django.core.paginator import InvalidPage
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import six
|
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from django.utils.translation import ugettext
|
from django.utils.translation import ugettext
|
||||||
|
@ -151,7 +149,7 @@ class ChangeList:
|
||||||
use_distinct = use_distinct or lookup_needs_distinct(self.lookup_opts, key)
|
use_distinct = use_distinct or lookup_needs_distinct(self.lookup_opts, key)
|
||||||
return filter_specs, bool(filter_specs), lookup_params, use_distinct
|
return filter_specs, bool(filter_specs), lookup_params, use_distinct
|
||||||
except FieldDoesNotExist as e:
|
except FieldDoesNotExist as e:
|
||||||
six.reraise(IncorrectLookupParameters, IncorrectLookupParameters(e), sys.exc_info()[2])
|
raise IncorrectLookupParameters(e) from e
|
||||||
|
|
||||||
def get_query_string(self, new_params=None, remove=None):
|
def get_query_string(self, new_params=None, remove=None):
|
||||||
if new_params is None:
|
if new_params is None:
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import sys
|
|
||||||
|
|
||||||
import cx_Oracle
|
import cx_Oracle
|
||||||
|
|
||||||
from django.db.backends.oracle.introspection import DatabaseIntrospection
|
from django.db.backends.oracle.introspection import DatabaseIntrospection
|
||||||
from django.utils import six
|
|
||||||
|
|
||||||
|
|
||||||
class OracleIntrospection(DatabaseIntrospection):
|
class OracleIntrospection(DatabaseIntrospection):
|
||||||
|
@ -24,12 +21,11 @@ class OracleIntrospection(DatabaseIntrospection):
|
||||||
(table_name.upper(), geo_col.upper())
|
(table_name.upper(), geo_col.upper())
|
||||||
)
|
)
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
except Exception as msg:
|
except Exception as exc:
|
||||||
new_msg = (
|
raise Exception(
|
||||||
'Could not find entry in USER_SDO_GEOM_METADATA '
|
'Could not find entry in USER_SDO_GEOM_METADATA '
|
||||||
'corresponding to "%s"."%s"\n'
|
'corresponding to "%s"."%s"' % (table_name, geo_col)
|
||||||
'Error message: %s.') % (table_name, geo_col, msg)
|
) from exc
|
||||||
six.reraise(Exception, Exception(new_msg), sys.exc_info()[2])
|
|
||||||
|
|
||||||
# TODO: Research way to find a more specific geometry field type for
|
# TODO: Research way to find a more specific geometry field type for
|
||||||
# the column's contents.
|
# the column's contents.
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import sys
|
|
||||||
from ctypes.util import find_library
|
from ctypes.util import find_library
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -6,7 +5,6 @@ from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db.backends.sqlite3.base import (
|
from django.db.backends.sqlite3.base import (
|
||||||
DatabaseWrapper as SQLiteDatabaseWrapper, SQLiteCursorWrapper,
|
DatabaseWrapper as SQLiteDatabaseWrapper, SQLiteCursorWrapper,
|
||||||
)
|
)
|
||||||
from django.utils import six
|
|
||||||
|
|
||||||
from .client import SpatiaLiteClient
|
from .client import SpatiaLiteClient
|
||||||
from .features import DatabaseFeatures
|
from .features import DatabaseFeatures
|
||||||
|
@ -53,11 +51,10 @@ class DatabaseWrapper(SQLiteDatabaseWrapper):
|
||||||
cur = conn.cursor(factory=SQLiteCursorWrapper)
|
cur = conn.cursor(factory=SQLiteCursorWrapper)
|
||||||
try:
|
try:
|
||||||
cur.execute("SELECT load_extension(%s)", (self.spatialite_lib,))
|
cur.execute("SELECT load_extension(%s)", (self.spatialite_lib,))
|
||||||
except Exception as msg:
|
except Exception as exc:
|
||||||
new_msg = (
|
raise ImproperlyConfigured(
|
||||||
'Unable to load the SpatiaLite library extension '
|
'Unable to load the SpatiaLite library extension "%s"' % self.spatialite_lib
|
||||||
'"%s" because: %s') % (self.spatialite_lib, msg)
|
) from exc
|
||||||
six.reraise(ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2])
|
|
||||||
cur.close()
|
cur.close()
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ https://web.archive.org/web/20130407175746/http://www.gaia-gis.it/gaia-sins/spat
|
||||||
http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.1.html
|
http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.1.html
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
from django.contrib.gis.db.backends.base.operations import \
|
from django.contrib.gis.db.backends.base.operations import \
|
||||||
BaseSpatialOperations
|
BaseSpatialOperations
|
||||||
|
@ -15,7 +14,6 @@ from django.contrib.gis.geometry.backend import Geometry
|
||||||
from django.contrib.gis.measure import Distance
|
from django.contrib.gis.measure import Distance
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db.backends.sqlite3.operations import DatabaseOperations
|
from django.db.backends.sqlite3.operations import DatabaseOperations
|
||||||
from django.utils import six
|
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,12 +121,13 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
"""Determine the version of the SpatiaLite library."""
|
"""Determine the version of the SpatiaLite library."""
|
||||||
try:
|
try:
|
||||||
version = self.spatialite_version_tuple()[1:]
|
version = self.spatialite_version_tuple()[1:]
|
||||||
except Exception as msg:
|
except Exception as exc:
|
||||||
new_msg = (
|
raise ImproperlyConfigured(
|
||||||
'Cannot determine the SpatiaLite version for the "%s" '
|
'Cannot determine the SpatiaLite version for the "%s" database. '
|
||||||
'database (error was "%s"). Was the SpatiaLite initialization '
|
'Was the SpatiaLite initialization SQL loaded on this database?' % (
|
||||||
'SQL loaded on this database?') % (self.connection.settings_dict['NAME'], msg)
|
self.connection.settings_dict['NAME'],
|
||||||
six.reraise(ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2])
|
)
|
||||||
|
) from exc
|
||||||
if version < (4, 0, 0):
|
if version < (4, 0, 0):
|
||||||
raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 4.0.0 and above.')
|
raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 4.0.0 and above.')
|
||||||
return version
|
return version
|
||||||
|
|
|
@ -20,7 +20,6 @@ from django.contrib.gis.gdal.field import (
|
||||||
)
|
)
|
||||||
from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
|
from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
|
||||||
from django.db import connections, models, router, transaction
|
from django.db import connections, models, router, transaction
|
||||||
from django.utils import six
|
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
|
|
||||||
|
@ -456,9 +455,10 @@ class LayerMapping:
|
||||||
|
|
||||||
# Creating the CoordTransform object
|
# Creating the CoordTransform object
|
||||||
return CoordTransform(self.source_srs, target_srs)
|
return CoordTransform(self.source_srs, target_srs)
|
||||||
except Exception as msg:
|
except Exception as exc:
|
||||||
new_msg = 'Could not translate between the data source and model geometry: %s' % msg
|
raise LayerMapError(
|
||||||
six.reraise(LayerMapError, LayerMapError(new_msg), sys.exc_info()[2])
|
'Could not translate between the data source and model geometry.'
|
||||||
|
) from exc
|
||||||
|
|
||||||
def geometry_field(self):
|
def geometry_field(self):
|
||||||
"Returns the GeometryField instance associated with the geographic column."
|
"Returns the GeometryField instance associated with the geographic column."
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import sys
|
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
@ -6,7 +5,6 @@ from django.core.management.base import BaseCommand, CommandError
|
||||||
from django.core.management.color import no_style
|
from django.core.management.color import no_style
|
||||||
from django.core.management.sql import emit_post_migrate_signal, sql_flush
|
from django.core.management.sql import emit_post_migrate_signal, sql_flush
|
||||||
from django.db import DEFAULT_DB_ALIAS, connections, transaction
|
from django.db import DEFAULT_DB_ALIAS, connections, transaction
|
||||||
from django.utils import six
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
@ -67,16 +65,17 @@ Are you sure you want to do this?
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
for sql in sql_list:
|
for sql in sql_list:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
except Exception as e:
|
except Exception as exc:
|
||||||
new_msg = (
|
raise CommandError(
|
||||||
"Database %s couldn't be flushed. Possible reasons:\n"
|
"Database %s couldn't be flushed. Possible reasons:\n"
|
||||||
" * The database isn't running or isn't configured correctly.\n"
|
" * The database isn't running or isn't configured correctly.\n"
|
||||||
" * At least one of the expected database tables doesn't exist.\n"
|
" * At least one of the expected database tables doesn't exist.\n"
|
||||||
" * The SQL was invalid.\n"
|
" * The SQL was invalid.\n"
|
||||||
"Hint: Look at the output of 'django-admin sqlflush'. "
|
"Hint: Look at the output of 'django-admin sqlflush'. "
|
||||||
"That's the SQL this command wasn't able to run.\n"
|
"That's the SQL this command wasn't able to run.\n" % (
|
||||||
"The full error: %s") % (connection.settings_dict['NAME'], e)
|
connection.settings_dict['NAME'],
|
||||||
six.reraise(CommandError, CommandError(new_msg), sys.exc_info()[2])
|
)
|
||||||
|
) from exc
|
||||||
|
|
||||||
# Empty sql_list may signify an empty database and post_migrate would then crash
|
# Empty sql_list may signify an empty database and post_migrate would then crash
|
||||||
if sql_list and not inhibit_post_migrate:
|
if sql_list and not inhibit_post_migrate:
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import PIPE, Popen
|
||||||
|
|
||||||
from django.apps import apps as installed_apps
|
from django.apps import apps as installed_apps
|
||||||
from django.utils import six
|
|
||||||
from django.utils.crypto import get_random_string
|
from django.utils.crypto import get_random_string
|
||||||
from django.utils.encoding import DEFAULT_LOCALE_ENCODING, force_text
|
from django.utils.encoding import DEFAULT_LOCALE_ENCODING, force_text
|
||||||
|
|
||||||
|
@ -18,10 +16,8 @@ def popen_wrapper(args, os_err_exc_type=CommandError, stdout_encoding='utf-8'):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
p = Popen(args, shell=False, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt')
|
p = Popen(args, shell=False, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt')
|
||||||
except OSError as e:
|
except OSError as err:
|
||||||
strerror = force_text(e.strerror, DEFAULT_LOCALE_ENCODING, strings_only=True)
|
raise os_err_exc_type('Error executing %s' % args[0]) from err
|
||||||
six.reraise(os_err_exc_type, os_err_exc_type('Error executing %s: %s' %
|
|
||||||
(args[0], strerror)), sys.exc_info()[2])
|
|
||||||
output, errors = p.communicate()
|
output, errors = p.communicate()
|
||||||
return (
|
return (
|
||||||
force_text(output, stdout_encoding, strings_only=True, errors='strict'),
|
force_text(output, stdout_encoding, strings_only=True, errors='strict'),
|
||||||
|
|
|
@ -5,14 +5,12 @@ Serialize data to/from JSON
|
||||||
import datetime
|
import datetime
|
||||||
import decimal
|
import decimal
|
||||||
import json
|
import json
|
||||||
import sys
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from django.core.serializers.base import DeserializationError
|
from django.core.serializers.base import DeserializationError
|
||||||
from django.core.serializers.python import (
|
from django.core.serializers.python import (
|
||||||
Deserializer as PythonDeserializer, Serializer as PythonSerializer,
|
Deserializer as PythonDeserializer, Serializer as PythonSerializer,
|
||||||
)
|
)
|
||||||
from django.utils import six
|
|
||||||
from django.utils.duration import duration_iso_string
|
from django.utils.duration import duration_iso_string
|
||||||
from django.utils.functional import Promise
|
from django.utils.functional import Promise
|
||||||
from django.utils.timezone import is_aware
|
from django.utils.timezone import is_aware
|
||||||
|
@ -77,11 +75,10 @@ def Deserializer(stream_or_string, **options):
|
||||||
objects = json.loads(stream_or_string)
|
objects = json.loads(stream_or_string)
|
||||||
for obj in PythonDeserializer(objects, **options):
|
for obj in PythonDeserializer(objects, **options):
|
||||||
yield obj
|
yield obj
|
||||||
except GeneratorExit:
|
except (GeneratorExit, DeserializationError):
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as exc:
|
||||||
# Map to deserializer error
|
raise DeserializationError() from exc
|
||||||
six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
|
|
||||||
|
|
||||||
|
|
||||||
class DjangoJSONEncoder(json.JSONEncoder):
|
class DjangoJSONEncoder(json.JSONEncoder):
|
||||||
|
|
|
@ -6,7 +6,6 @@ Requires PyYaml (http://pyyaml.org/), but that's checked for in __init__.
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import decimal
|
import decimal
|
||||||
import sys
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
@ -16,7 +15,6 @@ from django.core.serializers.python import (
|
||||||
Deserializer as PythonDeserializer, Serializer as PythonSerializer,
|
Deserializer as PythonDeserializer, Serializer as PythonSerializer,
|
||||||
)
|
)
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import six
|
|
||||||
|
|
||||||
# Use the C (faster) implementation if possible
|
# Use the C (faster) implementation if possible
|
||||||
try:
|
try:
|
||||||
|
@ -78,8 +76,7 @@ def Deserializer(stream_or_string, **options):
|
||||||
try:
|
try:
|
||||||
for obj in PythonDeserializer(yaml.load(stream, Loader=SafeLoader), **options):
|
for obj in PythonDeserializer(yaml.load(stream, Loader=SafeLoader), **options):
|
||||||
yield obj
|
yield obj
|
||||||
except GeneratorExit:
|
except (GeneratorExit, DeserializationError):
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as exc:
|
||||||
# Map to deserializer error
|
raise DeserializationError() from exc
|
||||||
six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ from wsgiref import simple_server
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
from django.utils import six
|
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
|
|
||||||
__all__ = ('WSGIServer', 'WSGIRequestHandler')
|
__all__ = ('WSGIServer', 'WSGIRequestHandler')
|
||||||
|
@ -43,16 +42,11 @@ def get_internal_wsgi_application():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return import_string(app_path)
|
return import_string(app_path)
|
||||||
except ImportError as e:
|
except ImportError as err:
|
||||||
msg = (
|
raise ImproperlyConfigured(
|
||||||
"WSGI application '%(app_path)s' could not be loaded; "
|
"WSGI application '%s' could not be loaded; "
|
||||||
"Error importing module: '%(exception)s'" % ({
|
"Error importing module." % app_path
|
||||||
'app_path': app_path,
|
) from err
|
||||||
'exception': e,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
six.reraise(ImproperlyConfigured, ImproperlyConfigured(msg),
|
|
||||||
sys.exc_info()[2])
|
|
||||||
|
|
||||||
|
|
||||||
def is_broken_pipe_error():
|
def is_broken_pipe_error():
|
||||||
|
|
|
@ -4,23 +4,21 @@ MySQL database backend for Django.
|
||||||
Requires mysqlclient: https://pypi.python.org/pypi/mysqlclient/
|
Requires mysqlclient: https://pypi.python.org/pypi/mysqlclient/
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db import utils
|
from django.db import utils
|
||||||
from django.db.backends import utils as backend_utils
|
from django.db.backends import utils as backend_utils
|
||||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||||
from django.utils import six
|
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.safestring import SafeBytes, SafeText
|
from django.utils.safestring import SafeBytes, SafeText
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import MySQLdb as Database
|
import MySQLdb as Database
|
||||||
except ImportError as e:
|
except ImportError as err:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
'Error loading MySQLdb module: %s.\n'
|
'Error loading MySQLdb module.\n'
|
||||||
'Did you install mysqlclient or MySQL-python?' % e
|
'Did you install mysqlclient or MySQL-python?'
|
||||||
)
|
) from err
|
||||||
|
|
||||||
from MySQLdb.constants import CLIENT, FIELD_TYPE # isort:skip
|
from MySQLdb.constants import CLIENT, FIELD_TYPE # isort:skip
|
||||||
from MySQLdb.converters import conversions # isort:skip
|
from MySQLdb.converters import conversions # isort:skip
|
||||||
|
@ -88,7 +86,7 @@ class CursorWrapper:
|
||||||
# Map some error codes to IntegrityError, since they seem to be
|
# Map some error codes to IntegrityError, since they seem to be
|
||||||
# misclassified and Django would prefer the more logical place.
|
# misclassified and Django would prefer the more logical place.
|
||||||
if e.args[0] in self.codes_for_integrityerror:
|
if e.args[0] in self.codes_for_integrityerror:
|
||||||
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
|
raise utils.IntegrityError(*tuple(e.args))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def executemany(self, query, args):
|
def executemany(self, query, args):
|
||||||
|
@ -98,7 +96,7 @@ class CursorWrapper:
|
||||||
# Map some error codes to IntegrityError, since they seem to be
|
# Map some error codes to IntegrityError, since they seem to be
|
||||||
# misclassified and Django would prefer the more logical place.
|
# misclassified and Django would prefer the more logical place.
|
||||||
if e.args[0] in self.codes_for_integrityerror:
|
if e.args[0] in self.codes_for_integrityerror:
|
||||||
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
|
raise utils.IntegrityError(*tuple(e.args))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
|
|
|
@ -7,13 +7,11 @@ import datetime
|
||||||
import decimal
|
import decimal
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db import utils
|
from django.db import utils
|
||||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||||
from django.utils import six
|
|
||||||
from django.utils.encoding import force_bytes, force_text
|
from django.utils.encoding import force_bytes, force_text
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
|
@ -261,7 +259,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
x = e.args[0]
|
x = e.args[0]
|
||||||
if hasattr(x, 'code') and hasattr(x, 'message') \
|
if hasattr(x, 'code') and hasattr(x, 'message') \
|
||||||
and x.code == 2091 and 'ORA-02291' in x.message:
|
and x.code == 2091 and 'ORA-02291' in x.message:
|
||||||
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
|
raise utils.IntegrityError(*tuple(e.args))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Oracle doesn't support releasing savepoints. But we fake them when query
|
# Oracle doesn't support releasing savepoints. But we fake them when query
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import sys
|
|
||||||
import warnings
|
import warnings
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from functools import total_ordering
|
from functools import total_ordering
|
||||||
|
|
||||||
from django.db.migrations.state import ProjectState
|
from django.db.migrations.state import ProjectState
|
||||||
from django.utils import six
|
|
||||||
from django.utils.datastructures import OrderedSet
|
from django.utils.datastructures import OrderedSet
|
||||||
|
|
||||||
from .exceptions import CircularDependencyError, NodeNotFoundError
|
from .exceptions import CircularDependencyError, NodeNotFoundError
|
||||||
|
@ -178,16 +176,12 @@ class MigrationGraph:
|
||||||
replaced = set(replaced)
|
replaced = set(replaced)
|
||||||
try:
|
try:
|
||||||
replacement_node = self.node_map[replacement]
|
replacement_node = self.node_map[replacement]
|
||||||
except KeyError as exc:
|
except KeyError as err:
|
||||||
exc_value = NodeNotFoundError(
|
raise NodeNotFoundError(
|
||||||
"Unable to find replacement node %r. It was either never added"
|
"Unable to find replacement node %r. It was either never added"
|
||||||
" to the migration graph, or has been removed." % (replacement, ),
|
" to the migration graph, or has been removed." % (replacement, ),
|
||||||
replacement
|
replacement
|
||||||
)
|
) from err
|
||||||
exc_value.__cause__ = exc
|
|
||||||
if not hasattr(exc, '__traceback__'):
|
|
||||||
exc.__traceback__ = sys.exc_info()[2]
|
|
||||||
six.reraise(NodeNotFoundError, exc_value, sys.exc_info()[2])
|
|
||||||
for replaced_key in replaced:
|
for replaced_key in replaced:
|
||||||
self.nodes.pop(replaced_key, None)
|
self.nodes.pop(replaced_key, None)
|
||||||
replaced_node = self.node_map.pop(replaced_key, None)
|
replaced_node = self.node_map.pop(replaced_key, None)
|
||||||
|
@ -218,16 +212,12 @@ class MigrationGraph:
|
||||||
self.nodes.pop(replacement, None)
|
self.nodes.pop(replacement, None)
|
||||||
try:
|
try:
|
||||||
replacement_node = self.node_map.pop(replacement)
|
replacement_node = self.node_map.pop(replacement)
|
||||||
except KeyError as exc:
|
except KeyError as err:
|
||||||
exc_value = NodeNotFoundError(
|
raise NodeNotFoundError(
|
||||||
"Unable to remove replacement node %r. It was either never added"
|
"Unable to remove replacement node %r. It was either never added"
|
||||||
" to the migration graph, or has been removed already." % (replacement, ),
|
" to the migration graph, or has been removed already." % (replacement, ),
|
||||||
replacement
|
replacement
|
||||||
)
|
) from err
|
||||||
exc_value.__cause__ = exc
|
|
||||||
if not hasattr(exc, '__traceback__'):
|
|
||||||
exc.__traceback__ = sys.exc_info()[2]
|
|
||||||
six.reraise(NodeNotFoundError, exc_value, sys.exc_info()[2])
|
|
||||||
replaced_nodes = set()
|
replaced_nodes = set()
|
||||||
replaced_nodes_parents = set()
|
replaced_nodes_parents = set()
|
||||||
for key in replaced:
|
for key in replaced:
|
||||||
|
|
|
@ -6,7 +6,6 @@ from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.migrations.graph import MigrationGraph
|
from django.db.migrations.graph import MigrationGraph
|
||||||
from django.db.migrations.recorder import MigrationRecorder
|
from django.db.migrations.recorder import MigrationRecorder
|
||||||
from django.utils import six
|
|
||||||
|
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
AmbiguityError, BadMigrationError, InconsistentMigrationHistory,
|
AmbiguityError, BadMigrationError, InconsistentMigrationHistory,
|
||||||
|
@ -256,7 +255,7 @@ class MigrationLoader:
|
||||||
is_replaced = any(candidate in self.graph.nodes for candidate in candidates)
|
is_replaced = any(candidate in self.graph.nodes for candidate in candidates)
|
||||||
if not is_replaced:
|
if not is_replaced:
|
||||||
tries = ', '.join('%s.%s' % c for c in candidates)
|
tries = ', '.join('%s.%s' % c for c in candidates)
|
||||||
exc_value = NodeNotFoundError(
|
raise NodeNotFoundError(
|
||||||
"Migration {0} depends on nonexistent node ('{1}', '{2}'). "
|
"Migration {0} depends on nonexistent node ('{1}', '{2}'). "
|
||||||
"Django tried to replace migration {1}.{2} with any of [{3}] "
|
"Django tried to replace migration {1}.{2} with any of [{3}] "
|
||||||
"but wasn't able to because some of the replaced migrations "
|
"but wasn't able to because some of the replaced migrations "
|
||||||
|
@ -264,11 +263,7 @@ class MigrationLoader:
|
||||||
exc.origin, exc.node[0], exc.node[1], tries
|
exc.origin, exc.node[0], exc.node[1], tries
|
||||||
),
|
),
|
||||||
exc.node
|
exc.node
|
||||||
)
|
) from exc
|
||||||
exc_value.__cause__ = exc
|
|
||||||
if not hasattr(exc, '__traceback__'):
|
|
||||||
exc.__traceback__ = sys.exc_info()[2]
|
|
||||||
six.reraise(NodeNotFoundError, exc_value, sys.exc_info()[2])
|
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
def check_consistent_history(self, connection):
|
def check_consistent_history(self, connection):
|
||||||
|
|
|
@ -21,7 +21,7 @@ from django.db.models.fields import AutoField
|
||||||
from django.db.models.functions import Trunc
|
from django.db.models.functions import Trunc
|
||||||
from django.db.models.query_utils import InvalidQuery, Q
|
from django.db.models.query_utils import InvalidQuery, Q
|
||||||
from django.db.models.sql.constants import CURSOR
|
from django.db.models.sql.constants import CURSOR
|
||||||
from django.utils import six, timezone
|
from django.utils import timezone
|
||||||
from django.utils.functional import cached_property, partition
|
from django.utils.functional import cached_property, partition
|
||||||
from django.utils.version import get_version
|
from django.utils.version import get_version
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ class QuerySet:
|
||||||
return self.get(**lookup), False
|
return self.get(**lookup), False
|
||||||
except self.model.DoesNotExist:
|
except self.model.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
six.reraise(*exc_info)
|
raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
|
||||||
|
|
||||||
def _extract_model_params(self, defaults, **kwargs):
|
def _extract_model_params(self, defaults, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -5,7 +5,6 @@ from threading import local
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.utils import six
|
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
|
|
||||||
|
@ -90,7 +89,7 @@ class DatabaseErrorWrapper:
|
||||||
# the connection unusable.
|
# the connection unusable.
|
||||||
if dj_exc_type not in (DataError, IntegrityError):
|
if dj_exc_type not in (DataError, IntegrityError):
|
||||||
self.wrapper.errors_occurred = True
|
self.wrapper.errors_occurred = True
|
||||||
six.reraise(dj_exc_type, dj_exc_value, traceback)
|
raise dj_exc_value.with_traceback(traceback)
|
||||||
|
|
||||||
def __call__(self, func):
|
def __call__(self, func):
|
||||||
# Note that we are intentionally not using @wraps here for performance
|
# Note that we are intentionally not using @wraps here for performance
|
||||||
|
|
|
@ -7,7 +7,6 @@ import datetime
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import uuid
|
import uuid
|
||||||
from decimal import Decimal, DecimalException
|
from decimal import Decimal, DecimalException
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
@ -26,7 +25,7 @@ from django.forms.widgets import (
|
||||||
SplitDateTimeWidget, SplitHiddenDateTimeWidget, TextInput, TimeInput,
|
SplitDateTimeWidget, SplitHiddenDateTimeWidget, TextInput, TimeInput,
|
||||||
URLInput,
|
URLInput,
|
||||||
)
|
)
|
||||||
from django.utils import formats, six
|
from django.utils import formats
|
||||||
from django.utils.dateparse import parse_duration
|
from django.utils.dateparse import parse_duration
|
||||||
from django.utils.duration import duration_string
|
from django.utils.duration import duration_string
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
|
@ -650,12 +649,12 @@ class ImageField(FileField):
|
||||||
# Pillow doesn't detect the MIME type of all formats. In those
|
# Pillow doesn't detect the MIME type of all formats. In those
|
||||||
# cases, content_type will be None.
|
# cases, content_type will be None.
|
||||||
f.content_type = Image.MIME.get(image.format)
|
f.content_type = Image.MIME.get(image.format)
|
||||||
except Exception:
|
except Exception as exc:
|
||||||
# Pillow doesn't recognize it as an image.
|
# Pillow doesn't recognize it as an image.
|
||||||
six.reraise(ValidationError, ValidationError(
|
raise ValidationError(
|
||||||
self.error_messages['invalid_image'],
|
self.error_messages['invalid_image'],
|
||||||
code='invalid_image',
|
code='invalid_image',
|
||||||
), sys.exc_info()[2])
|
) from exc
|
||||||
if hasattr(f, 'seek') and callable(f.seek):
|
if hasattr(f, 'seek') and callable(f.seek):
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
return f
|
return f
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import json
|
import json
|
||||||
import sys
|
|
||||||
from collections import UserList
|
from collections import UserList
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError # backwards compatibility
|
from django.core.exceptions import ValidationError # backwards compatibility
|
||||||
from django.utils import six, timezone
|
from django.utils import timezone
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.html import escape, format_html, format_html_join, html_safe
|
from django.utils.html import escape, format_html, format_html_join, html_safe
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
@ -156,18 +155,14 @@ def from_current_timezone(value):
|
||||||
current_timezone = timezone.get_current_timezone()
|
current_timezone = timezone.get_current_timezone()
|
||||||
try:
|
try:
|
||||||
return timezone.make_aware(value, current_timezone)
|
return timezone.make_aware(value, current_timezone)
|
||||||
except Exception:
|
except Exception as exc:
|
||||||
message = _(
|
raise ValidationError(
|
||||||
'%(datetime)s couldn\'t be interpreted '
|
_('%(datetime)s couldn\'t be interpreted '
|
||||||
'in time zone %(current_timezone)s; it '
|
'in time zone %(current_timezone)s; it '
|
||||||
'may be ambiguous or it may not exist.'
|
'may be ambiguous or it may not exist.'),
|
||||||
)
|
|
||||||
params = {'datetime': value, 'current_timezone': current_timezone}
|
|
||||||
six.reraise(ValidationError, ValidationError(
|
|
||||||
message,
|
|
||||||
code='ambiguous_timezone',
|
code='ambiguous_timezone',
|
||||||
params=params,
|
params={'datetime': value, 'current_timezone': current_timezone}
|
||||||
), sys.exc_info()[2])
|
) from exc
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ file upload handlers for processing.
|
||||||
import base64
|
import base64
|
||||||
import binascii
|
import binascii
|
||||||
import cgi
|
import cgi
|
||||||
import sys
|
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -17,7 +16,6 @@ from django.core.exceptions import (
|
||||||
from django.core.files.uploadhandler import (
|
from django.core.files.uploadhandler import (
|
||||||
SkipFile, StopFutureHandlers, StopUpload,
|
SkipFile, StopFutureHandlers, StopUpload,
|
||||||
)
|
)
|
||||||
from django.utils import six
|
|
||||||
from django.utils.datastructures import MultiValueDict
|
from django.utils.datastructures import MultiValueDict
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.text import unescape_entities
|
from django.utils.text import unescape_entities
|
||||||
|
@ -247,10 +245,9 @@ class MultiPartParser:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
chunk = base64.b64decode(stripped_chunk)
|
chunk = base64.b64decode(stripped_chunk)
|
||||||
except Exception as e:
|
except Exception as exc:
|
||||||
# Since this is only a chunk, any error is an unfixable error.
|
# Since this is only a chunk, any error is an unfixable error.
|
||||||
msg = "Could not decode base64 data: %r" % e
|
raise MultiPartParserError("Could not decode base64 data.") from exc
|
||||||
six.reraise(MultiPartParserError, MultiPartParserError(msg), sys.exc_info()[2])
|
|
||||||
|
|
||||||
for i, handler in enumerate(handlers):
|
for i, handler in enumerate(handlers):
|
||||||
chunk_length = len(chunk)
|
chunk_length = len(chunk)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import copy
|
import copy
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from urllib.parse import quote, urlencode, urljoin, urlsplit
|
from urllib.parse import quote, urlencode, urljoin, urlsplit
|
||||||
|
@ -12,7 +11,6 @@ from django.core.exceptions import (
|
||||||
)
|
)
|
||||||
from django.core.files import uploadhandler
|
from django.core.files import uploadhandler
|
||||||
from django.http.multipartparser import MultiPartParser, MultiPartParserError
|
from django.http.multipartparser import MultiPartParser, MultiPartParserError
|
||||||
from django.utils import six
|
|
||||||
from django.utils.datastructures import ImmutableList, MultiValueDict
|
from django.utils.datastructures import ImmutableList, MultiValueDict
|
||||||
from django.utils.encoding import escape_uri_path, force_bytes, iri_to_uri
|
from django.utils.encoding import escape_uri_path, force_bytes, iri_to_uri
|
||||||
from django.utils.http import is_same_domain, limited_parse_qsl
|
from django.utils.http import is_same_domain, limited_parse_qsl
|
||||||
|
@ -263,7 +261,7 @@ class HttpRequest:
|
||||||
try:
|
try:
|
||||||
self._body = self.read()
|
self._body = self.read()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
six.reraise(UnreadablePostError, UnreadablePostError(*e.args), sys.exc_info()[2])
|
raise UnreadablePostError(*e.args) from e
|
||||||
self._stream = BytesIO(self._body)
|
self._stream = BytesIO(self._body)
|
||||||
return self._body
|
return self._body
|
||||||
|
|
||||||
|
@ -322,14 +320,14 @@ class HttpRequest:
|
||||||
try:
|
try:
|
||||||
return self._stream.read(*args, **kwargs)
|
return self._stream.read(*args, **kwargs)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
six.reraise(UnreadablePostError, UnreadablePostError(*e.args), sys.exc_info()[2])
|
raise UnreadablePostError(*e.args) from e
|
||||||
|
|
||||||
def readline(self, *args, **kwargs):
|
def readline(self, *args, **kwargs):
|
||||||
self._read_started = True
|
self._read_started = True
|
||||||
try:
|
try:
|
||||||
return self._stream.readline(*args, **kwargs)
|
return self._stream.readline(*args, **kwargs)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
six.reraise(UnreadablePostError, UnreadablePostError(*e.args), sys.exc_info()[2])
|
raise UnreadablePostError(*e.args) from e
|
||||||
|
|
||||||
def xreadlines(self):
|
def xreadlines(self):
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import sys
|
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from pkgutil import walk_packages
|
from pkgutil import walk_packages
|
||||||
|
|
||||||
|
@ -8,7 +7,6 @@ from django.template import TemplateDoesNotExist
|
||||||
from django.template.context import make_context
|
from django.template.context import make_context
|
||||||
from django.template.engine import Engine
|
from django.template.engine import Engine
|
||||||
from django.template.library import InvalidTemplateLibrary
|
from django.template.library import InvalidTemplateLibrary
|
||||||
from django.utils import six
|
|
||||||
|
|
||||||
from .base import BaseEngine
|
from .base import BaseEngine
|
||||||
|
|
||||||
|
@ -83,7 +81,7 @@ def reraise(exc, backend):
|
||||||
Reraise TemplateDoesNotExist while maintaining template debug information.
|
Reraise TemplateDoesNotExist while maintaining template debug information.
|
||||||
"""
|
"""
|
||||||
new = copy_exception(exc, backend)
|
new = copy_exception(exc, backend)
|
||||||
six.reraise(exc.__class__, new, sys.exc_info()[2])
|
raise new from exc
|
||||||
|
|
||||||
|
|
||||||
def get_installed_libraries():
|
def get_installed_libraries():
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import sys
|
|
||||||
|
|
||||||
import jinja2
|
import jinja2
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template import TemplateDoesNotExist, TemplateSyntaxError
|
from django.template import TemplateDoesNotExist, TemplateSyntaxError
|
||||||
from django.utils import six
|
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
|
|
||||||
|
@ -41,15 +38,11 @@ class Jinja2(BaseEngine):
|
||||||
try:
|
try:
|
||||||
return Template(self.env.get_template(template_name), self)
|
return Template(self.env.get_template(template_name), self)
|
||||||
except jinja2.TemplateNotFound as exc:
|
except jinja2.TemplateNotFound as exc:
|
||||||
six.reraise(
|
raise TemplateDoesNotExist(exc.name, backend=self) from exc
|
||||||
TemplateDoesNotExist,
|
|
||||||
TemplateDoesNotExist(exc.name, backend=self),
|
|
||||||
sys.exc_info()[2],
|
|
||||||
)
|
|
||||||
except jinja2.TemplateSyntaxError as exc:
|
except jinja2.TemplateSyntaxError as exc:
|
||||||
new = TemplateSyntaxError(exc.args)
|
new = TemplateSyntaxError(exc.args)
|
||||||
new.template_debug = get_exception_info(exc)
|
new.template_debug = get_exception_info(exc)
|
||||||
six.reraise(TemplateSyntaxError, new, sys.exc_info()[2])
|
raise new from exc
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def template_context_processors(self):
|
def template_context_processors(self):
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import sys
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template import Library, Node, TemplateSyntaxError, Variable
|
from django.template import Library, Node, TemplateSyntaxError, Variable
|
||||||
from django.template.base import TOKEN_TEXT, TOKEN_VAR, render_value_in_context
|
from django.template.base import TOKEN_TEXT, TOKEN_VAR, render_value_in_context
|
||||||
from django.template.defaulttags import token_kwargs
|
from django.template.defaulttags import token_kwargs
|
||||||
from django.utils import six, translation
|
from django.utils import translation
|
||||||
from django.utils.safestring import SafeData, mark_safe
|
from django.utils.safestring import SafeData, mark_safe
|
||||||
|
|
||||||
register = Library()
|
register = Library()
|
||||||
|
@ -388,8 +386,9 @@ def do_translate(parser, token):
|
||||||
try:
|
try:
|
||||||
value = remaining.pop(0)
|
value = remaining.pop(0)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
msg = "No argument provided to the '%s' tag for the context option." % bits[0]
|
raise TemplateSyntaxError(
|
||||||
six.reraise(TemplateSyntaxError, TemplateSyntaxError(msg), sys.exc_info()[2])
|
"No argument provided to the '%s' tag for the context option." % bits[0]
|
||||||
|
)
|
||||||
if value in invalid_context:
|
if value in invalid_context:
|
||||||
raise TemplateSyntaxError(
|
raise TemplateSyntaxError(
|
||||||
"Invalid argument '%s' provided to the '%s' tag for the context option" % (value, bits[0]),
|
"Invalid argument '%s' provided to the '%s' tag for the context option" % (value, bits[0]),
|
||||||
|
@ -399,8 +398,9 @@ def do_translate(parser, token):
|
||||||
try:
|
try:
|
||||||
value = remaining.pop(0)
|
value = remaining.pop(0)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
msg = "No argument provided to the '%s' tag for the as option." % bits[0]
|
raise TemplateSyntaxError(
|
||||||
six.reraise(TemplateSyntaxError, TemplateSyntaxError(msg), sys.exc_info()[2])
|
"No argument provided to the '%s' tag for the as option." % bits[0]
|
||||||
|
)
|
||||||
asvar = value
|
asvar = value
|
||||||
else:
|
else:
|
||||||
raise TemplateSyntaxError(
|
raise TemplateSyntaxError(
|
||||||
|
@ -481,18 +481,18 @@ def do_block_translate(parser, token):
|
||||||
value = remaining_bits.pop(0)
|
value = remaining_bits.pop(0)
|
||||||
value = parser.compile_filter(value)
|
value = parser.compile_filter(value)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = (
|
raise TemplateSyntaxError(
|
||||||
'"context" in %r tag expected '
|
'"context" in %r tag expected exactly one argument.' % bits[0]
|
||||||
'exactly one argument.') % bits[0]
|
)
|
||||||
six.reraise(TemplateSyntaxError, TemplateSyntaxError(msg), sys.exc_info()[2])
|
|
||||||
elif option == "trimmed":
|
elif option == "trimmed":
|
||||||
value = True
|
value = True
|
||||||
elif option == "asvar":
|
elif option == "asvar":
|
||||||
try:
|
try:
|
||||||
value = remaining_bits.pop(0)
|
value = remaining_bits.pop(0)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
msg = "No argument provided to the '%s' tag for the asvar option." % bits[0]
|
raise TemplateSyntaxError(
|
||||||
six.reraise(TemplateSyntaxError, TemplateSyntaxError(msg), sys.exc_info()[2])
|
"No argument provided to the '%s' tag for the asvar option." % bits[0]
|
||||||
|
)
|
||||||
asvar = value
|
asvar = value
|
||||||
else:
|
else:
|
||||||
raise TemplateSyntaxError('Unknown argument for %r tag: %r.' %
|
raise TemplateSyntaxError('Unknown argument for %r tag: %r.' %
|
||||||
|
|
|
@ -20,7 +20,6 @@ from django.template import TemplateDoesNotExist
|
||||||
from django.test import signals
|
from django.test import signals
|
||||||
from django.test.utils import ContextList
|
from django.test.utils import ContextList
|
||||||
from django.urls import resolve
|
from django.urls import resolve
|
||||||
from django.utils import six
|
|
||||||
from django.utils.encoding import force_bytes, uri_to_iri
|
from django.utils.encoding import force_bytes, uri_to_iri
|
||||||
from django.utils.functional import SimpleLazyObject, curry
|
from django.utils.functional import SimpleLazyObject, curry
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
|
@ -494,7 +493,7 @@ class Client(RequestFactory):
|
||||||
if self.exc_info:
|
if self.exc_info:
|
||||||
exc_info = self.exc_info
|
exc_info = self.exc_info
|
||||||
self.exc_info = None
|
self.exc_info = None
|
||||||
six.reraise(*exc_info)
|
raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
|
||||||
|
|
||||||
# Save the client and request that stimulated the response.
|
# Save the client and request that stimulated the response.
|
||||||
response.client = self
|
response.client = self
|
||||||
|
|
|
@ -40,7 +40,6 @@ import _thread
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.signals import request_finished
|
from django.core.signals import request_finished
|
||||||
from django.utils import six
|
|
||||||
|
|
||||||
# This import does nothing, but it's necessary to avoid some race conditions
|
# This import does nothing, but it's necessary to avoid some race conditions
|
||||||
# in the threading module. See http://code.djangoproject.com/ticket/2330 .
|
# in the threading module. See http://code.djangoproject.com/ticket/2330 .
|
||||||
|
@ -247,7 +246,7 @@ def check_errors(fn):
|
||||||
def raise_last_exception():
|
def raise_last_exception():
|
||||||
global _exception
|
global _exception
|
||||||
if _exception is not None:
|
if _exception is not None:
|
||||||
six.reraise(*_exception)
|
raise _exception[0](_exception[1]).with_traceback(_exception[2])
|
||||||
|
|
||||||
|
|
||||||
def ensure_echo_on():
|
def ensure_echo_on():
|
||||||
|
|
|
@ -2,7 +2,6 @@ import base64
|
||||||
import calendar
|
import calendar
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import warnings
|
import warnings
|
||||||
from binascii import Error as BinasciiError
|
from binascii import Error as BinasciiError
|
||||||
|
@ -13,7 +12,6 @@ from urllib.parse import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.core.exceptions import TooManyFieldsSent
|
from django.core.exceptions import TooManyFieldsSent
|
||||||
from django.utils import six
|
|
||||||
from django.utils.datastructures import MultiValueDict
|
from django.utils.datastructures import MultiValueDict
|
||||||
from django.utils.deprecation import RemovedInDjango21Warning
|
from django.utils.deprecation import RemovedInDjango21Warning
|
||||||
from django.utils.encoding import force_bytes, force_str, force_text
|
from django.utils.encoding import force_bytes, force_str, force_text
|
||||||
|
@ -163,8 +161,8 @@ def parse_http_date(date):
|
||||||
sec = int(m.group('sec'))
|
sec = int(m.group('sec'))
|
||||||
result = datetime.datetime(year, month, day, hour, min, sec)
|
result = datetime.datetime(year, month, day, hour, min, sec)
|
||||||
return calendar.timegm(result.utctimetuple())
|
return calendar.timegm(result.utctimetuple())
|
||||||
except Exception:
|
except Exception as exc:
|
||||||
six.reraise(ValueError, ValueError("%r is not a valid date" % date), sys.exc_info()[2])
|
raise ValueError("%r is not a valid date" % date) from exc
|
||||||
|
|
||||||
|
|
||||||
def parse_http_date_safe(date):
|
def parse_http_date_safe(date):
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from importlib.util import find_spec as importlib_find
|
from importlib.util import find_spec as importlib_find
|
||||||
|
|
||||||
from django.utils import six
|
|
||||||
|
|
||||||
|
|
||||||
def import_string(dotted_path):
|
def import_string(dotted_path):
|
||||||
"""
|
"""
|
||||||
|
@ -14,18 +11,17 @@ def import_string(dotted_path):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
module_path, class_name = dotted_path.rsplit('.', 1)
|
module_path, class_name = dotted_path.rsplit('.', 1)
|
||||||
except ValueError:
|
except ValueError as err:
|
||||||
msg = "%s doesn't look like a module path" % dotted_path
|
raise ImportError("%s doesn't look like a module path" % dotted_path) from err
|
||||||
six.reraise(ImportError, ImportError(msg), sys.exc_info()[2])
|
|
||||||
|
|
||||||
module = import_module(module_path)
|
module = import_module(module_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return getattr(module, class_name)
|
return getattr(module, class_name)
|
||||||
except AttributeError:
|
except AttributeError as err:
|
||||||
msg = 'Module "%s" does not define a "%s" attribute/class' % (
|
raise ImportError('Module "%s" does not define a "%s" attribute/class' % (
|
||||||
module_path, class_name)
|
module_path, class_name)
|
||||||
six.reraise(ImportError, ImportError(msg), sys.exc_info()[2])
|
) from err
|
||||||
|
|
||||||
|
|
||||||
def autodiscover_modules(*args, **kwargs):
|
def autodiscover_modules(*args, **kwargs):
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import sys
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db import ProgrammingError
|
from django.db import ProgrammingError
|
||||||
from django.utils import six
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from django.contrib.gis.db.backends.postgis.operations import PostGISOperations
|
from django.contrib.gis.db.backends.postgis.operations import PostGISOperations
|
||||||
|
@ -19,7 +17,7 @@ except ImproperlyConfigured as e:
|
||||||
if e.args and e.args[0].startswith('Could not import user-defined GEOMETRY_BACKEND'):
|
if e.args and e.args[0].startswith('Could not import user-defined GEOMETRY_BACKEND'):
|
||||||
HAS_POSTGRES = False
|
HAS_POSTGRES = False
|
||||||
else:
|
else:
|
||||||
six.reraise(*sys.exc_info())
|
raise
|
||||||
|
|
||||||
|
|
||||||
if HAS_POSTGRES:
|
if HAS_POSTGRES:
|
||||||
|
|
Loading…
Reference in New Issue