Ticket #18003: 18003.diff

File 18003.diff, 13.8 KB (added by jrothenbuhler, 3 years ago)
  • django/http/multipartparser.py

     
    66"""
    77
    88import cgi
     9import sys
    910from django.conf import settings
    1011from django.core.exceptions import SuspiciousOperation
    1112from django.utils.datastructures import MultiValueDict
     
    198199                                    chunk = str(chunk).decode('base64')
    199200                                except Exception, e:
    200201                                    # Since this is only a chunk, any error is an unfixable error.
    201                                     raise MultiPartParserError("Could not decode base64 data: %r" % e)
     202                                    msg = "Could not decode base64 data: %r" % e
     203                                    raise MultiPartParserError, MultiPartParserError(msg), sys.exc_info()[2]
    202204
    203205                            for i, handler in enumerate(handlers):
    204206                                chunk_length = len(chunk)
  • django/test/testcases.py

     
    11161116                    for port in range(extremes[0], extremes[1] + 1):
    11171117                        possible_ports.append(port)
    11181118        except Exception:
    1119             raise ImproperlyConfigured('Invalid address ("%s") for live '
    1120                 'server.' % specified_address)
     1119            msg = 'Invalid address ("%s") for live server.' % specified_address
     1120            raise ImproperlyConfigured, ImproperlyConfigured(msg), sys.exc_info()[2]
    11211121        cls.server_thread = LiveServerThread(
    11221122            host, possible_ports, connections_override)
    11231123        cls.server_thread.daemon = True
  • django/forms/util.py

     
     1import sys
     2
    13from django.conf import settings
    24from django.utils.html import conditional_escape
    35from django.utils.encoding import StrAndUnicode, force_unicode
     
    6769        try:
    6870            return timezone.make_aware(value, current_timezone)
    6971        except Exception, e:
    70             raise ValidationError(_('%(datetime)s couldn\'t be interpreted '
    71                                     'in time zone %(current_timezone)s; it '
    72                                     'may be ambiguous or it may not exist.')
    73                                   % {'datetime': value,
    74                                      'current_timezone': current_timezone})
     72            msg = _(
     73                '%(datetime)s couldn\'t be interpreted '
     74                'in time zone %(current_timezone)s; it '
     75                'may be ambiguous or it may not exist.') % {'datetime': value, 'current_timezone': current_timezone}
     76            raise ValidationError, ValidationError(msg), sys.exc_info()[2]
    7577    return value
    7678
    7779def to_current_timezone(value):
  • django/forms/fields.py

     
    88import datetime
    99import os
    1010import re
     11import sys
    1112import urlparse
    1213from decimal import Decimal, DecimalException
    1314try:
     
    579580            # raised. Catch and re-raise.
    580581            raise
    581582        except Exception: # Python Imaging Library doesn't recognize it as an image
    582             raise ValidationError(self.error_messages['invalid_image'])
     583            raise ValidationError, ValidationError(self.error_messages['invalid_image']), sys.exc_info()[2]
    583584        if hasattr(f, 'seek') and callable(f.seek):
    584585            f.seek(0)
    585586        return f
  • django/core/servers/basehttp.py

     
    119119        try:
    120120            super(WSGIServer, self).server_bind()
    121121        except Exception, e:
    122             raise WSGIServerException(e)
     122            raise WSGIServerException, WSGIServerException(e), sys.exc_info()[2]
    123123        self.setup_environ()
    124124
    125125
  • django/core/serializers/json.py

     
    44
    55import datetime
    66import decimal
     7import sys
    78from StringIO import StringIO
    89
    910from django.core.serializers.base import DeserializationError
     
    4445        raise
    4546    except Exception, e:
    4647        # Map to deserializer error
    47         raise DeserializationError(e)
     48        raise DeserializationError, DeserializationError(e), sys.exc_info()[2]
    4849
    4950
    5051class DjangoJSONEncoder(simplejson.JSONEncoder):
  • django/core/serializers/pyyaml.py

     
    66
    77from StringIO import StringIO
    88import decimal
     9import sys
    910import yaml
    1011
    1112from django.db import models
     
    5960        raise
    6061    except Exception, e:
    6162        # Map to deserializer error
    62         raise DeserializationError(e)
     63        raise DeserializationError, DeserializationError(e), sys.exc_info()[2]
  • django/core/management/commands/flush.py

     
     1import sys
     2
    13from optparse import make_option
    24
    35from django.conf import settings
     
    5759                    cursor.execute(sql)
    5860            except Exception, e:
    5961                transaction.rollback_unless_managed(using=db)
    60                 raise CommandError("""Database %s couldn't be flushed. Possible reasons:
    61   * The database isn't running or isn't configured correctly.
    62   * At least one of the expected database tables doesn't exist.
    63   * The SQL was invalid.
    64 Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
    65 The full error: %s""" % (connection.settings_dict['NAME'], e))
     62                new_msg = (
     63                    "Database %s couldn't be flushed. Possible reasons:\n"
     64                    "  * The database isn't running or isn't configured correctly.\n"
     65                    "  * At least one of the expected database tables doesn't exist.\n"
     66                    "  * The SQL was invalid.\n"
     67                    "Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.\n"
     68                    "The full error: %s") % (connection.settings_dict['NAME'], e)
     69                raise CommandError, CommandError(new_msg), sys.exc_info()[2]
    6670            transaction.commit_unless_managed(using=db)
    6771
    6872            # Emit the post sync signal. This allows individual
  • django/templatetags/i18n.py

     
    11import re
     2import sys
    23
    34from django.template import (Node, Variable, TemplateSyntaxError,
    45    TokenParser, Library, TOKEN_TEXT, TOKEN_VAR)
     
    415416                value = remaining_bits.pop(0)
    416417                value = parser.compile_filter(value)
    417418            except Exception:
    418                 raise TemplateSyntaxError('"context" in %r tag expected '
    419                                           'exactly one argument.' % bits[0])
     419                msg = (
     420                    '"context" in %r tag expected '
     421                    'exactly one argument.') % bits[0]
     422                raise TemplateSyntaxError, TemplateSyntaxError(msg), sys.exc_info()[2]
    420423        else:
    421424            raise TemplateSyntaxError('Unknown argument for %r tag: %r.' %
    422425                                      (bits[0], option))
  • django/contrib/gis/db/backends/spatialite/base.py

     
     1import sys
    12from ctypes.util import find_library
    23from django.conf import settings
    34
     
    5758            try:
    5859                cur.execute("SELECT load_extension(%s)", (self.spatialite_lib,))
    5960            except Exception, msg:
    60                 raise ImproperlyConfigured('Unable to load the SpatiaLite library extension '
    61                                            '"%s" because: %s' % (self.spatialite_lib, msg))
     61                new_msg = (
     62                    'Unable to load the SpatiaLite library extension '
     63                    '"%s" because: %s') % (self.spatialite_lib, msg)
     64                raise ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2]
    6265            return cur
    6366        else:
    6467            return self.connection.cursor(factory=SQLiteCursorWrapper)
  • django/contrib/gis/db/backends/spatialite/operations.py

     
    11import re
     2import sys
    23from decimal import Decimal
    34
    45from django.contrib.gis.db.backends.base import BaseSpatialOperations
     
    123124        except ImproperlyConfigured:
    124125            raise
    125126        except Exception, msg:
    126             raise ImproperlyConfigured('Cannot determine the SpatiaLite version for the "%s" '
    127                                        'database (error was "%s").  Was the SpatiaLite initialization '
    128                                        'SQL loaded on this database?' %
    129                                        (self.connection.settings_dict['NAME'], msg))
     127            new_msg = (
     128                'Cannot determine the SpatiaLite version for the "%s" '
     129                'database (error was "%s").  Was the SpatiaLite initialization '
     130                'SQL loaded on this database?') %
     131                                       (self.connection.settings_dict['NAME'], msg)
     132            raise ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2]
    130133
    131134        # Creating the GIS terms dictionary.
    132135        gis_terms = ['isnull']
  • django/contrib/gis/db/backends/oracle/introspection.py

     
     1import sys
    12import cx_Oracle
    23from django.db.backends.oracle.introspection import DatabaseIntrospection
    34
     
    1718                               (table_name.upper(), geo_col.upper()))
    1819                row = cursor.fetchone()
    1920            except Exception, msg:
    20                 raise Exception('Could not find entry in USER_SDO_GEOM_METADATA corresponding to "%s"."%s"\n'
    21                                 'Error message: %s.' % (table_name, geo_col, msg))
     21                new_msg = (
     22                    'Could not find entry in USER_SDO_GEOM_METADATA '
     23                    'corresponding to "%s"."%s"\n'
     24                    'Error message: %s.') % (table_name, geo_col, msg)
     25                raise Exception, Exception(new_msg), sys.exc_info()[2]
    2226
    2327            # TODO: Research way to find a more specific geometry field type for
    2428            # the column's contents.
  • django/contrib/gis/utils/layermapping.py

     
    431431            # Creating the CoordTransform object
    432432            return CoordTransform(self.source_srs, target_srs)
    433433        except Exception, msg:
    434             raise LayerMapError('Could not translate between the data source and model geometry: %s' % msg)
     434            new_msg = 'Could not translate between the data source and model geometry: %s' % msg
     435            raise LayerMapError, LayerMapError(new_msg), sys.exc_info()[2]
    435436
    436437    def geometry_field(self):
    437438        "Returns the GeometryField instance associated with the geographic column."
  • django/contrib/admin/views/main.py

     
    11import operator
     2import sys
    23
    34from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
    45from django.core.paginator import InvalidPage
     
    322323            # invalid if the keyword arguments are incorrect, or if the values
    323324            # are not in the correct type, so we might get FieldError,
    324325            # ValueError, ValidationError, or ?.
    325             raise IncorrectLookupParameters(e)
     326            raise IncorrectLookupParameters, IncorrectLookupParameters(e), sys.exc_info()[2]
    326327
    327328        # Use select_related() if one of the list_display options is a field
    328329        # with a relationship and the provided queryset doesn't already have
  • django/utils/http.py

     
    136136        result = datetime.datetime(year, month, day, hour, min, sec)
    137137        return calendar.timegm(result.utctimetuple())
    138138    except Exception:
    139         raise ValueError("%r is not a valid date" % date)
     139        raise ValueError, ValueError("%r is not a valid date" % date), sys.exc_info()[2]
    140140
    141141def parse_http_date_safe(date):
    142142    """
Back to Top