Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed two bugs in 59a3520.

* StandardError doesn't exist any more under Python 3.
* Python 2.6 still allows `raise "foo"`.
  • Loading branch information...
commit 1b100d7beed757246df1da8417590a6f2aabc2bc 1 parent 59a3520
@aaugustin aaugustin authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 django/db/utils.py
View
9 django/db/utils.py
@@ -14,7 +14,7 @@
DEFAULT_DB_ALIAS = 'default'
-class Error(StandardError):
+class Error(Exception if six.PY3 else StandardError):
pass
@@ -81,7 +81,12 @@ def __exit__(self, exc_type, exc_value, traceback):
):
db_exc_type = getattr(self.database, dj_exc_type.__name__)
if issubclass(exc_type, db_exc_type):
- dj_exc_value = dj_exc_type(*tuple(exc_value.args))
+ # Under Python 2.6, exc_value can still be a string.
+ try:
+ args = tuple(exc_value.args)
+ except AttributeError:
+ args = (exc_value,)
+ dj_exc_value = dj_exc_type(*args)
if six.PY3:
dj_exc_value.__cause__ = exc_value
six.reraise(dj_exc_type, dj_exc_value, traceback)
Please sign in to comment.
Something went wrong with that request. Please try again.