Code

Ticket #18003: 18003.diff

File 18003.diff, 13.8 KB (added by jrothenbuhler, 2 years ago)
Line 
1Index: django/http/multipartparser.py
2===================================================================
3--- django/http/multipartparser.py      (revision 17906)
4+++ django/http/multipartparser.py      (working copy)
5@@ -6,6 +6,7 @@
6 """
7 
8 import cgi
9+import sys
10 from django.conf import settings
11 from django.core.exceptions import SuspiciousOperation
12 from django.utils.datastructures import MultiValueDict
13@@ -198,7 +199,8 @@
14                                     chunk = str(chunk).decode('base64')
15                                 except Exception, e:
16                                     # Since this is only a chunk, any error is an unfixable error.
17-                                    raise MultiPartParserError("Could not decode base64 data: %r" % e)
18+                                    msg = "Could not decode base64 data: %r" % e
19+                                    raise MultiPartParserError, MultiPartParserError(msg), sys.exc_info()[2]
20 
21                             for i, handler in enumerate(handlers):
22                                 chunk_length = len(chunk)
23Index: django/test/testcases.py
24===================================================================
25--- django/test/testcases.py    (revision 17906)
26+++ django/test/testcases.py    (working copy)
27@@ -1116,8 +1116,8 @@
28                     for port in range(extremes[0], extremes[1] + 1):
29                         possible_ports.append(port)
30         except Exception:
31-            raise ImproperlyConfigured('Invalid address ("%s") for live '
32-                'server.' % specified_address)
33+            msg = 'Invalid address ("%s") for live server.' % specified_address
34+            raise ImproperlyConfigured, ImproperlyConfigured(msg), sys.exc_info()[2]
35         cls.server_thread = LiveServerThread(
36             host, possible_ports, connections_override)
37         cls.server_thread.daemon = True
38Index: django/forms/util.py
39===================================================================
40--- django/forms/util.py        (revision 17906)
41+++ django/forms/util.py        (working copy)
42@@ -1,3 +1,5 @@
43+import sys
44+
45 from django.conf import settings
46 from django.utils.html import conditional_escape
47 from django.utils.encoding import StrAndUnicode, force_unicode
48@@ -67,11 +69,11 @@
49         try:
50             return timezone.make_aware(value, current_timezone)
51         except Exception, e:
52-            raise ValidationError(_('%(datetime)s couldn\'t be interpreted '
53-                                    'in time zone %(current_timezone)s; it '
54-                                    'may be ambiguous or it may not exist.')
55-                                  % {'datetime': value,
56-                                     'current_timezone': current_timezone})
57+            msg = _(
58+                '%(datetime)s couldn\'t be interpreted '
59+                'in time zone %(current_timezone)s; it '
60+                'may be ambiguous or it may not exist.') % {'datetime': value, 'current_timezone': current_timezone}
61+            raise ValidationError, ValidationError(msg), sys.exc_info()[2]
62     return value
63 
64 def to_current_timezone(value):
65Index: django/forms/fields.py
66===================================================================
67--- django/forms/fields.py      (revision 17906)
68+++ django/forms/fields.py      (working copy)
69@@ -8,6 +8,7 @@
70 import datetime
71 import os
72 import re
73+import sys
74 import urlparse
75 from decimal import Decimal, DecimalException
76 try:
77@@ -579,7 +580,7 @@
78             # raised. Catch and re-raise.
79             raise
80         except Exception: # Python Imaging Library doesn't recognize it as an image
81-            raise ValidationError(self.error_messages['invalid_image'])
82+            raise ValidationError, ValidationError(self.error_messages['invalid_image']), sys.exc_info()[2]
83         if hasattr(f, 'seek') and callable(f.seek):
84             f.seek(0)
85         return f
86Index: django/core/servers/basehttp.py
87===================================================================
88--- django/core/servers/basehttp.py     (revision 17906)
89+++ django/core/servers/basehttp.py     (working copy)
90@@ -119,7 +119,7 @@
91         try:
92             super(WSGIServer, self).server_bind()
93         except Exception, e:
94-            raise WSGIServerException(e)
95+            raise WSGIServerException, WSGIServerException(e), sys.exc_info()[2]
96         self.setup_environ()
97 
98 
99Index: django/core/serializers/json.py
100===================================================================
101--- django/core/serializers/json.py     (revision 17906)
102+++ django/core/serializers/json.py     (working copy)
103@@ -4,6 +4,7 @@
104 
105 import datetime
106 import decimal
107+import sys
108 from StringIO import StringIO
109 
110 from django.core.serializers.base import DeserializationError
111@@ -44,7 +45,7 @@
112         raise
113     except Exception, e:
114         # Map to deserializer error
115-        raise DeserializationError(e)
116+        raise DeserializationError, DeserializationError(e), sys.exc_info()[2]
117 
118 
119 class DjangoJSONEncoder(simplejson.JSONEncoder):
120Index: django/core/serializers/pyyaml.py
121===================================================================
122--- django/core/serializers/pyyaml.py   (revision 17906)
123+++ django/core/serializers/pyyaml.py   (working copy)
124@@ -6,6 +6,7 @@
125 
126 from StringIO import StringIO
127 import decimal
128+import sys
129 import yaml
130 
131 from django.db import models
132@@ -59,4 +60,4 @@
133         raise
134     except Exception, e:
135         # Map to deserializer error
136-        raise DeserializationError(e)
137+        raise DeserializationError, DeserializationError(e), sys.exc_info()[2]
138Index: django/core/management/commands/flush.py
139===================================================================
140--- django/core/management/commands/flush.py    (revision 17906)
141+++ django/core/management/commands/flush.py    (working copy)
142@@ -1,3 +1,5 @@
143+import sys
144+
145 from optparse import make_option
146 
147 from django.conf import settings
148@@ -57,12 +59,14 @@
149                     cursor.execute(sql)
150             except Exception, e:
151                 transaction.rollback_unless_managed(using=db)
152-                raise CommandError("""Database %s couldn't be flushed. Possible reasons:
153-  * The database isn't running or isn't configured correctly.
154-  * At least one of the expected database tables doesn't exist.
155-  * The SQL was invalid.
156-Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
157-The full error: %s""" % (connection.settings_dict['NAME'], e))
158+                new_msg = (
159+                    "Database %s couldn't be flushed. Possible reasons:\n"
160+                    "  * The database isn't running or isn't configured correctly.\n"
161+                    "  * At least one of the expected database tables doesn't exist.\n"
162+                    "  * The SQL was invalid.\n"
163+                    "Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.\n"
164+                    "The full error: %s") % (connection.settings_dict['NAME'], e)
165+                raise CommandError, CommandError(new_msg), sys.exc_info()[2]
166             transaction.commit_unless_managed(using=db)
167 
168             # Emit the post sync signal. This allows individual
169Index: django/templatetags/i18n.py
170===================================================================
171--- django/templatetags/i18n.py (revision 17906)
172+++ django/templatetags/i18n.py (working copy)
173@@ -1,4 +1,5 @@
174 import re
175+import sys
176 
177 from django.template import (Node, Variable, TemplateSyntaxError,
178     TokenParser, Library, TOKEN_TEXT, TOKEN_VAR)
179@@ -415,8 +416,10 @@
180                 value = remaining_bits.pop(0)
181                 value = parser.compile_filter(value)
182             except Exception:
183-                raise TemplateSyntaxError('"context" in %r tag expected '
184-                                          'exactly one argument.' % bits[0])
185+                msg = (
186+                    '"context" in %r tag expected '
187+                    'exactly one argument.') % bits[0]
188+                raise TemplateSyntaxError, TemplateSyntaxError(msg), sys.exc_info()[2]
189         else:
190             raise TemplateSyntaxError('Unknown argument for %r tag: %r.' %
191                                       (bits[0], option))
192Index: django/contrib/gis/db/backends/spatialite/base.py
193===================================================================
194--- django/contrib/gis/db/backends/spatialite/base.py   (revision 17906)
195+++ django/contrib/gis/db/backends/spatialite/base.py   (working copy)
196@@ -1,3 +1,4 @@
197+import sys
198 from ctypes.util import find_library
199 from django.conf import settings
200 
201@@ -57,8 +58,10 @@
202             try:
203                 cur.execute("SELECT load_extension(%s)", (self.spatialite_lib,))
204             except Exception, msg:
205-                raise ImproperlyConfigured('Unable to load the SpatiaLite library extension '
206-                                           '"%s" because: %s' % (self.spatialite_lib, msg))
207+                new_msg = (
208+                    'Unable to load the SpatiaLite library extension '
209+                    '"%s" because: %s') % (self.spatialite_lib, msg)
210+                raise ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2]
211             return cur
212         else:
213             return self.connection.cursor(factory=SQLiteCursorWrapper)
214Index: django/contrib/gis/db/backends/spatialite/operations.py
215===================================================================
216--- django/contrib/gis/db/backends/spatialite/operations.py     (revision 17906)
217+++ django/contrib/gis/db/backends/spatialite/operations.py     (working copy)
218@@ -1,4 +1,5 @@
219 import re
220+import sys
221 from decimal import Decimal
222 
223 from django.contrib.gis.db.backends.base import BaseSpatialOperations
224@@ -123,10 +124,12 @@
225         except ImproperlyConfigured:
226             raise
227         except Exception, msg:
228-            raise ImproperlyConfigured('Cannot determine the SpatiaLite version for the "%s" '
229-                                       'database (error was "%s").  Was the SpatiaLite initialization '
230-                                       'SQL loaded on this database?' %
231-                                       (self.connection.settings_dict['NAME'], msg))
232+            new_msg = (
233+                'Cannot determine the SpatiaLite version for the "%s" '
234+                'database (error was "%s").  Was the SpatiaLite initialization '
235+                'SQL loaded on this database?') %
236+                                       (self.connection.settings_dict['NAME'], msg)
237+            raise ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2]
238 
239         # Creating the GIS terms dictionary.
240         gis_terms = ['isnull']
241Index: django/contrib/gis/db/backends/oracle/introspection.py
242===================================================================
243--- django/contrib/gis/db/backends/oracle/introspection.py      (revision 17906)
244+++ django/contrib/gis/db/backends/oracle/introspection.py      (working copy)
245@@ -1,3 +1,4 @@
246+import sys
247 import cx_Oracle
248 from django.db.backends.oracle.introspection import DatabaseIntrospection
249 
250@@ -17,8 +18,11 @@
251                                (table_name.upper(), geo_col.upper()))
252                 row = cursor.fetchone()
253             except Exception, msg:
254-                raise Exception('Could not find entry in USER_SDO_GEOM_METADATA corresponding to "%s"."%s"\n'
255-                                'Error message: %s.' % (table_name, geo_col, msg))
256+                new_msg = (
257+                    'Could not find entry in USER_SDO_GEOM_METADATA '
258+                    'corresponding to "%s"."%s"\n'
259+                    'Error message: %s.') % (table_name, geo_col, msg)
260+                raise Exception, Exception(new_msg), sys.exc_info()[2]
261 
262             # TODO: Research way to find a more specific geometry field type for
263             # the column's contents.
264Index: django/contrib/gis/utils/layermapping.py
265===================================================================
266--- django/contrib/gis/utils/layermapping.py    (revision 17906)
267+++ django/contrib/gis/utils/layermapping.py    (working copy)
268@@ -431,7 +431,8 @@
269             # Creating the CoordTransform object
270             return CoordTransform(self.source_srs, target_srs)
271         except Exception, msg:
272-            raise LayerMapError('Could not translate between the data source and model geometry: %s' % msg)
273+            new_msg = 'Could not translate between the data source and model geometry: %s' % msg
274+            raise LayerMapError, LayerMapError(new_msg), sys.exc_info()[2]
275 
276     def geometry_field(self):
277         "Returns the GeometryField instance associated with the geographic column."
278Index: django/contrib/admin/views/main.py
279===================================================================
280--- django/contrib/admin/views/main.py  (revision 17906)
281+++ django/contrib/admin/views/main.py  (working copy)
282@@ -1,4 +1,5 @@
283 import operator
284+import sys
285 
286 from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
287 from django.core.paginator import InvalidPage
288@@ -322,7 +323,7 @@
289             # invalid if the keyword arguments are incorrect, or if the values
290             # are not in the correct type, so we might get FieldError,
291             # ValueError, ValidationError, or ?.
292-            raise IncorrectLookupParameters(e)
293+            raise IncorrectLookupParameters, IncorrectLookupParameters(e), sys.exc_info()[2]
294 
295         # Use select_related() if one of the list_display options is a field
296         # with a relationship and the provided queryset doesn't already have
297Index: django/utils/http.py
298===================================================================
299--- django/utils/http.py        (revision 17906)
300+++ django/utils/http.py        (working copy)
301@@ -136,7 +136,7 @@
302         result = datetime.datetime(year, month, day, hour, min, sec)
303         return calendar.timegm(result.utctimetuple())
304     except Exception:
305-        raise ValueError("%r is not a valid date" % date)
306+        raise ValueError, ValueError("%r is not a valid date" % date), sys.exc_info()[2]
307 
308 def parse_http_date_safe(date):
309     """