Ticket #18003: 18003.diff
File 18003.diff, 13.8 KB (added by , 13 years ago) |
---|
-
django/http/multipartparser.py
6 6 """ 7 7 8 8 import cgi 9 import sys 9 10 from django.conf import settings 10 11 from django.core.exceptions import SuspiciousOperation 11 12 from django.utils.datastructures import MultiValueDict … … 198 199 chunk = str(chunk).decode('base64') 199 200 except Exception, e: 200 201 # 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] 202 204 203 205 for i, handler in enumerate(handlers): 204 206 chunk_length = len(chunk) -
django/test/testcases.py
1116 1116 for port in range(extremes[0], extremes[1] + 1): 1117 1117 possible_ports.append(port) 1118 1118 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] 1121 1121 cls.server_thread = LiveServerThread( 1122 1122 host, possible_ports, connections_override) 1123 1123 cls.server_thread.daemon = True -
django/forms/util.py
1 import sys 2 1 3 from django.conf import settings 2 4 from django.utils.html import conditional_escape 3 5 from django.utils.encoding import StrAndUnicode, force_unicode … … 67 69 try: 68 70 return timezone.make_aware(value, current_timezone) 69 71 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] 75 77 return value 76 78 77 79 def to_current_timezone(value): -
django/forms/fields.py
8 8 import datetime 9 9 import os 10 10 import re 11 import sys 11 12 import urlparse 12 13 from decimal import Decimal, DecimalException 13 14 try: … … 579 580 # raised. Catch and re-raise. 580 581 raise 581 582 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] 583 584 if hasattr(f, 'seek') and callable(f.seek): 584 585 f.seek(0) 585 586 return f -
django/core/servers/basehttp.py
119 119 try: 120 120 super(WSGIServer, self).server_bind() 121 121 except Exception, e: 122 raise WSGIServerException (e)122 raise WSGIServerException, WSGIServerException(e), sys.exc_info()[2] 123 123 self.setup_environ() 124 124 125 125 -
django/core/serializers/json.py
4 4 5 5 import datetime 6 6 import decimal 7 import sys 7 8 from StringIO import StringIO 8 9 9 10 from django.core.serializers.base import DeserializationError … … 44 45 raise 45 46 except Exception, e: 46 47 # Map to deserializer error 47 raise DeserializationError (e)48 raise DeserializationError, DeserializationError(e), sys.exc_info()[2] 48 49 49 50 50 51 class DjangoJSONEncoder(simplejson.JSONEncoder): -
django/core/serializers/pyyaml.py
6 6 7 7 from StringIO import StringIO 8 8 import decimal 9 import sys 9 10 import yaml 10 11 11 12 from django.db import models … … 59 60 raise 60 61 except Exception, e: 61 62 # Map to deserializer error 62 raise DeserializationError (e)63 raise DeserializationError, DeserializationError(e), sys.exc_info()[2] -
django/core/management/commands/flush.py
1 import sys 2 1 3 from optparse import make_option 2 4 3 5 from django.conf import settings … … 57 59 cursor.execute(sql) 58 60 except Exception, e: 59 61 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] 66 70 transaction.commit_unless_managed(using=db) 67 71 68 72 # Emit the post sync signal. This allows individual -
django/templatetags/i18n.py
1 1 import re 2 import sys 2 3 3 4 from django.template import (Node, Variable, TemplateSyntaxError, 4 5 TokenParser, Library, TOKEN_TEXT, TOKEN_VAR) … … 415 416 value = remaining_bits.pop(0) 416 417 value = parser.compile_filter(value) 417 418 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] 420 423 else: 421 424 raise TemplateSyntaxError('Unknown argument for %r tag: %r.' % 422 425 (bits[0], option)) -
django/contrib/gis/db/backends/spatialite/base.py
1 import sys 1 2 from ctypes.util import find_library 2 3 from django.conf import settings 3 4 … … 57 58 try: 58 59 cur.execute("SELECT load_extension(%s)", (self.spatialite_lib,)) 59 60 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] 62 65 return cur 63 66 else: 64 67 return self.connection.cursor(factory=SQLiteCursorWrapper) -
django/contrib/gis/db/backends/spatialite/operations.py
1 1 import re 2 import sys 2 3 from decimal import Decimal 3 4 4 5 from django.contrib.gis.db.backends.base import BaseSpatialOperations … … 123 124 except ImproperlyConfigured: 124 125 raise 125 126 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] 130 133 131 134 # Creating the GIS terms dictionary. 132 135 gis_terms = ['isnull'] -
django/contrib/gis/db/backends/oracle/introspection.py
1 import sys 1 2 import cx_Oracle 2 3 from django.db.backends.oracle.introspection import DatabaseIntrospection 3 4 … … 17 18 (table_name.upper(), geo_col.upper())) 18 19 row = cursor.fetchone() 19 20 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] 22 26 23 27 # TODO: Research way to find a more specific geometry field type for 24 28 # the column's contents. -
django/contrib/gis/utils/layermapping.py
431 431 # Creating the CoordTransform object 432 432 return CoordTransform(self.source_srs, target_srs) 433 433 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] 435 436 436 437 def geometry_field(self): 437 438 "Returns the GeometryField instance associated with the geographic column." -
django/contrib/admin/views/main.py
1 1 import operator 2 import sys 2 3 3 4 from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured 4 5 from django.core.paginator import InvalidPage … … 322 323 # invalid if the keyword arguments are incorrect, or if the values 323 324 # are not in the correct type, so we might get FieldError, 324 325 # ValueError, ValidationError, or ?. 325 raise IncorrectLookupParameters (e)326 raise IncorrectLookupParameters, IncorrectLookupParameters(e), sys.exc_info()[2] 326 327 327 328 # Use select_related() if one of the list_display options is a field 328 329 # with a relationship and the provided queryset doesn't already have -
django/utils/http.py
136 136 result = datetime.datetime(year, month, day, hour, min, sec) 137 137 return calendar.timegm(result.utctimetuple()) 138 138 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] 140 140 141 141 def parse_http_date_safe(date): 142 142 """