Commit bc4111ba authored by konarkmodi's avatar konarkmodi Committed by Carl Meyer
Browse files

Fixed #18003 -- Preserved tracebacks when re-raising errors.

Thanks jrothenbuhler for draft patch, Konark Modi for updates.
parent 1fe90b28
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
import operator
import sys
import warnings
from functools import reduce

@@ -173,7 +174,7 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)):
                                lookup_needs_distinct(self.lookup_opts, key))
            return filter_specs, bool(filter_specs), lookup_params, use_distinct
        except FieldDoesNotExist as e:
            raise IncorrectLookupParameters(e)
            six.reraise(IncorrectLookupParameters, IncorrectLookupParameters(e), sys.exc_info()[2])

    def get_query_string(self, new_params=None, remove=None):
        if new_params is None: new_params = {}
+7 −2
Original line number Diff line number Diff line
import cx_Oracle
import sys
from django.db.backends.oracle.introspection import DatabaseIntrospection
from django.utils import six

class OracleIntrospection(DatabaseIntrospection):
    # Associating any OBJECTVAR instances with GeometryField.  Of course,
@@ -17,8 +19,11 @@ class OracleIntrospection(DatabaseIntrospection):
                               (table_name.upper(), geo_col.upper()))
                row = cursor.fetchone()
            except Exception as msg:
                raise Exception('Could not find entry in USER_SDO_GEOM_METADATA corresponding to "%s"."%s"\n'
                                'Error message: %s.' % (table_name, geo_col, msg))
                new_msg = (
                    'Could not find entry in USER_SDO_GEOM_METADATA '
                    'corresponding to "%s"."%s"\n'
                    'Error message: %s.') % (table_name, geo_col, msg)
                six.reraise(Exception, Exception(new_msg), sys.exc_info()[2])

            # TODO: Research way to find a more specific geometry field type for
            # the column's contents.
+6 −2
Original line number Diff line number Diff line
import sys
from ctypes.util import find_library
from django.conf import settings

@@ -8,6 +9,7 @@ from django.contrib.gis.db.backends.spatialite.client import SpatiaLiteClient
from django.contrib.gis.db.backends.spatialite.creation import SpatiaLiteCreation
from django.contrib.gis.db.backends.spatialite.introspection import SpatiaLiteIntrospection
from django.contrib.gis.db.backends.spatialite.operations import SpatiaLiteOperations
from django.utils import six

class DatabaseWrapper(SQLiteDatabaseWrapper):
    def __init__(self, *args, **kwargs):
@@ -50,7 +52,9 @@ class DatabaseWrapper(SQLiteDatabaseWrapper):
        try:
            cur.execute("SELECT load_extension(%s)", (self.spatialite_lib,))
        except Exception as msg:
            raise ImproperlyConfigured('Unable to load the SpatiaLite library extension '
                                       '"%s" because: %s' % (self.spatialite_lib, msg))
            new_msg = (
                'Unable to load the SpatiaLite library extension '
                '"%s" because: %s') % (self.spatialite_lib, msg)
            six.reraise(ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2])
        cur.close()
        return conn
+6 −4
Original line number Diff line number Diff line
import re
import sys
from decimal import Decimal

from django.contrib.gis.db.backends.base import BaseSpatialOperations
@@ -126,10 +127,11 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations):
        try:
            version = self.spatialite_version_tuple()[1:]
        except Exception as msg:
            raise ImproperlyConfigured('Cannot determine the SpatiaLite version for the "%s" '
            new_msg = (
                'Cannot determine the SpatiaLite version for the "%s" '
                'database (error was "%s").  Was the SpatiaLite initialization '
                                       'SQL loaded on this database?' %
                                       (self.connection.settings_dict['NAME'], msg))
                'SQL loaded on this database?') % (self.connection.settings_dict['NAME'], msg)
            six.reraise(ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2])
        if version < (2, 3, 0):
            raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions '
                                       '2.3.0 and above')
+2 −1
Original line number Diff line number Diff line
@@ -429,7 +429,8 @@ class LayerMapping(object):
            # Creating the CoordTransform object
            return CoordTransform(self.source_srs, target_srs)
        except Exception as msg:
            raise LayerMapError('Could not translate between the data source and model geometry: %s' % msg)
            new_msg = 'Could not translate between the data source and model geometry: %s' % msg
            six.reraise(LayerMapError, LayerMapError(new_msg), sys.exc_info()[2])

    def geometry_field(self):
        "Returns the GeometryField instance associated with the geographic column."
Loading