Fixed #28837 -- Fixed test client crash if an exception with more than one arg is raised.

Also removed usage of the problematic pattern elsewhere.

Regression in 6e55e1d88a.
This commit is contained in:
Nicolas Delaby 2017-11-23 17:18:03 +01:00 committed by Tim Graham
parent 7a6fbf36b1
commit 746caf3ef8
6 changed files with 21 additions and 8 deletions

View file

@ -4,7 +4,6 @@ The main QuerySet implementation. This provides the public API for the ORM.
import copy
import operator
import sys
import warnings
from collections import OrderedDict, namedtuple
from functools import lru_cache
@ -521,13 +520,12 @@ class QuerySet:
params = {k: v() if callable(v) else v for k, v in params.items()}
obj = self.create(**params)
return obj, True
except IntegrityError:
exc_info = sys.exc_info()
except IntegrityError as e:
try:
return self.get(**lookup), False
except self.model.DoesNotExist:
pass
raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
raise e
def _extract_model_params(self, defaults, **kwargs):
"""