diff options
author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-02-27 19:24:23 +0100 |
---|---|---|
committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-02-27 19:24:23 +0100 |
commit | 1b100d7beed757246df1da8417590a6f2aabc2bc (patch) | |
tree | 7d811e79916771171e0e6be9a45705864b6c17a9 /django/db/utils.py | |
parent | 59a352087591a26023412cbcb830cd1d34fc9b99 (diff) | |
download | django-1b100d7beed757246df1da8417590a6f2aabc2bc.tar.gz |
Fixed two bugs in 59a35208.
* StandardError doesn't exist any more under Python 3.
* Python 2.6 still allows `raise "foo"`.
Diffstat (limited to 'django/db/utils.py')
-rw-r--r-- | django/db/utils.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/django/db/utils.py b/django/db/utils.py index c841e06f3e..0c98cc23fd 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -14,7 +14,7 @@ from django.utils import six DEFAULT_DB_ALIAS = 'default' -class Error(StandardError): +class Error(Exception if six.PY3 else StandardError): pass @@ -81,7 +81,12 @@ class DatabaseErrorWrapper(object): ): 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) |